stop veiwing the form (1 Viewer)

steve111

Registered User.
Local time
Today, 19:36
Joined
Jan 30, 2014
Messages
429
hi

the code attached always shows me the pdf file and goes to the folder required
can the code be modified so it does not show me but just goes into the folder
I also would like a message to go to steve.kirk @ api.com to say this pdf is in the folder . but not send the pdf to him

could you please advise how to achieve this

Code:
Private Sub cmdPDF_Click()
   On Error GoTo Err_Handler
    
    Const FOLDER_EXISTS = 75
    Const MESSAGE_TEXT1 = "No current invoice."
    Const MESSAGE_TEXT2 = "No folder set for storing PDF files."
    Dim strFullPath As String
    Dim varFolder As Variant
    
   If Not IsNull(Me.[P/O Number]) Then
        ' build path to save PDF file
              varFolder = DLookup("Folderpath", "pdfFolder")
                 
              
        
        If IsNull(varFolder) Then
            MsgBox MESSAGE_TEXT2, vbExclamation, "Invalid Operation"
        Else
            ' create folder if does not exist
            varFolder = varFolder & "\" & Me.Supplier
            MkDir varFolder
            'strFullPath = varFolder & "\" & ME.CustomerName & " " & Me.Invoicenumber & ".pdf"
          strFullPath = varFolder & "\" & "Purchase order " & " " & Me.[P/O Number] & ".pdf"
            ' ensure current record is saved before creating PDF file
            Me.Dirty = False
           DoCmd.OutputTo acOutputReport, "order", acFormatPDF, strFullPath, True
        End If
    Else
        MsgBox MESSAGE_TEXT1, vbExclamation, "Invalid Operation"
    End If
 Exit_Here:
    Exit Sub
    
Err_Handler:
    Select Case Err.Number
        Case FOLDER_EXISTS
        Resume Next
        Case Else
        MsgBox Err.Description
        Resume Exit_Here
    End Select
    
    
    
    
    
    
    
    
    
 End Sub

many thanks
steve
 

smig

Registered User.
Local time
Today, 21:36
Joined
Nov 25, 2009
Messages
2,209
Here is a piece of code I'm using
Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


' --- this must be a function if you want to run from macro
Public Function OpenDirApp(WhatToOpen As String)

ShellExecute 0, "Open", WhatToOpen, vbNullString, vbNullString, SW_SHOWNORMAL

End Function
 

mattkorguk

Registered User.
Local time
Today, 19:36
Joined
Jun 26, 2007
Messages
301
You should be able to use;

Code:
Application.FollowHyperlink strFullPath

And the email;
Code:
DoCmd.SendObject acSendNoObject, , , steve.kirk @ api.com , , "PDF folder location", strFullPath, , True
 

Users who are viewing this thread

Top Bottom