Open a file

B

brian b

I'm using Access 97 and am trying to open *.pdf files from within a form
using a drop down box. Is this possible? If so, can someone provide me a
link or the code to do this? What I would like is to use the After Update
event, whereby the user would only need to select the file from the drop down
list to open the corresponding file.

Thanks
 
A

Allen Browne

You can use the FollowHyperlink method to open a filename with the
registered application.
 
A

Allan Murphy

Brian

This is a portion of code that I use to open a PDF file from the
switchboard.

Dim app_name As String

app_name = "c:\program files\adobe\acrobat 5.0\reader\acrord32.exe
j:\common\databases\SOS user guide V03.pdf"

Call Shell(app_name, 1)


Note:
c:\program files\adobe\acrobat 5.0\reader\acrord32.exe is the location for
the "exe" to open acrobat, you may need to change this line depending on
where your "exe" file is located.

j:\common\databases\SOS user guide V03.pdf i8s the location of the PDF file.

HTH

Allan Murphy

Email: [email protected]
 
B

brian b

Thanks for the quick responses.

I tried the FollowHyperlink, I would only get type mismatch errors(?).

I tried the code Mr. Murphy provided, works like a charm.
 
S

Sandro

brian b said:
I'm using Access 97 and am trying to open *.pdf files from within a form
using a drop down box. Is this possible? If so, can someone provide me a
link or the code to do this? What I would like is to use the After Update
event, whereby the user would only need to select the file from the drop down
list to open the corresponding file.

Thanks

Hi Brian, I'm writing you from Italy, so sorry for my not good english. I
hope I undestood your question so :

try like this :

Dim ret As Integer
ret = Shell("rundll32.exe url.dll,FileProtocolHandler " &
YoutPathAndFileName)

or with the ShellExecute API:

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
Const SW_SHOWNORMAL = 1


ShellExecute Me.hWnd, "Open", YourPath+NomeFile, vbNullString, YourPath,
SW_SHOWNORMAL
 
Top