[AccessD] Open PDF

David Emerson newsgrps at dalyn.co.nz
Wed Mar 14 16:01:35 CDT 2007


Rocky,

I use this function (Not sure where I came across it).  StrFile is 
the full path to the file to open.  It used Windows file association 
to know what program to open the file in:

Function RunApp(strFile As String, bytSize) As Boolean
     Dim lngRet As Long
     Dim varTaskID As Variant
     Dim strRet As String

     ' Enclose FilePath within double quotes so as to take care of 
embedded spaces if any.
     strFile = Chr(34) & strFile & Chr(34)
     ' bytSize = 1 for Normal Window, 3 for Maximized Window

     lngRet = ShellExecute(hWndAccessApp, vbNullString, strFile, 
vbNullString, vbNullString, bytSize)
     If lngRet > 32 Then 'Success
         strRet = vbNullString
         lngRet = -1
         RunApp = True
     Else
         RunApp = False
         Select Case lngRet
             Case 0 'InadequateMemory
                 MsgBox "Error:  Out of Memory/Resources!"
             Case 2 'FileNotFound
                 MsgBox "Error:  " & strFile & " not found."
             Case 3 'PathNotFound
                 MsgBox "Error:  Path not found for file " & strFile & "."
             Case 11 'BadFormat
                 MsgBox "Error:  Bad File Format for file " & strFile & "."
             Case 5
                 MsgBox "Error:  Unauthorized due to Security restrictions!"
             Case Else
                 MsgBox "Error: Unexpected error (Number " & lngRet & 
") for file " & strFile & "."
         End Select
     End If

End Function

Regards

David Emerson
Dalyn Software Ltd
999 Moonshine Rd, RD 1
Judgeford, Porirua
New Zealand 5381
Phone    0064 4 235-6782
Fax      0064 4 235-6783

At 15/03/2007, you wrote:
>Dear List:
>
>What is the best way to open a PDF file through VBA.  I have the full path
>and file name of the PDF file, but I can't count on the version or location
>of Acrobat on the target machines.
>
>MTIA,
>
>Rocky
>--
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com




More information about the AccessD mailing list