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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open A Document Using Registered Application With Minimal Code

Folders and Files

Open A Document Using Registered Application With Minimal Code

by  Norris68  Posted    (Edited  )
The following code will open a document using the application that is registered for that file type. This includes URLs, UNCs & paths.

Code:
Public Sub OpenDocument(DocPath As String)
Dim A As Long
A = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocPath, vbMaximizedFocus)
End Sub

e.g.
OpenDocument "http://www.tek-tips.com"
OpenDocument "C:\My Documents\Word.doc"
OpenDocument "C:\My Documents\Acrobat.pdf"
etc, etc.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top