[AccessD] Open PDF

Rocky Smolin at Beach Access Software rockysmolin at bchacc.com
Wed Mar 14 19:27:25 CDT 2007


Thanks David. I switched over to this instead of the FollowHyperlink
approach.  Worked perfectly once I figured out about getting the API
function declared.

The FollowHyperlink approach seems cleaner but there must be some drawback
to it.

Anyway, your code works fine with a second from Andy.  So I'll use it.

Thanks,

Rocky





 	
	

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of David Emerson
Sent: Wednesday, March 14, 2007 2:02 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Open PDF

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

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.11/721 - Release Date: 3/13/2007
4:51 PM
 




More information about the AccessD mailing list