Open .pdf file

T

Tracy

Is it possible to write vba code in a Word template that will open a .pdf
file with Acrobat Reader 6.0? If so, can you give me an example of the code?
Thank you.
 
J

Jonathan West

Tracy said:
Is it possible to write vba code in a Word template that will open a .pdf
file with Acrobat Reader 6.0? If so, can you give me an example of the
code?
Thank you.

Paste the following into a separate module

Option Explicit

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


Public Function OpenDoc(ByVal DocFile As String) As Long
OpenDoc = ShellExecute(0&, "open", DocFile, vbNullString, vbNullString,
vbNormalFocus)
End Function


If you pass a full pathname to the OpenDoc function, it will open the file
using its default application, whatever that might be. You can use this to
open a file of any type in its host application.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top