Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to open external files like pdf, jpg etc

Status
Not open for further replies.

v5652

Programmer
Mar 19, 2008
76
IN
i want get the solution to open .pdf files using Microsoft Access 2003.

i can open .doc or .xls files. but can't open pdf files or jpeg files using vba code.

if anyone know the solution to this,
please help.
thanks in advance.
 
I like using the ShellExecute api to open any files that are registered on the computer. There's a ready to use wrapper function here
Else, some like the Application.Followhyperlink method too (look it up in the help file).

Roy-Vidar
 
thanks RoyVidar for your immediate reply.
i will check the link and try it and will be back soon.
 
I have a database which users can view files from. I simply set the hyperlink address of a command button to the relevant file path and when they click the button it opens the file.

 
Try this

Code:
Public Function OpenDocument(strDocPath As String)

Dim Fl As Long
Fl = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & strDocPath, vbNormalFocus)
    
End Function

I think got it off this site
 
I generally use FollowHyperlink.

[tt]FollowHyperlink "C:\Docs\AnyFile.Doc"
FollowHyperlink "C:\Docs\"
FollowHyperlink "[/tt]

FollowHyperlink will open a file using the default application for registered extensions. You can open Websites, email (using mailto:), files, directories and so on.

 
thanks RoyVidar & thanks all of u.
i have tried the link given by RoyVidar and it works very well.
also i will try the followhyperlink.
thanks for your reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top