Opening a pdf while in word by macro

T

Tanya

I would like to set up a button with a macro attached
which will go to a directory with pdfs in it and be able
to click on a pdf and it then opens in adobe. Possible?
 
C

Cindy M -WordMVP-

Hi Tanya,
I would like to set up a button with a macro attached
which will go to a directory with pdfs in it and be able
to click on a pdf and it then opens in adobe. Possible?
Sure. Version of Word?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
J

Jonathan West

Tanya said:
I would like to set up a button with a macro attached
which will go to a directory with pdfs in it and be able
to click on a pdf and it then opens in adobe. Possible?

Yes, it is. Place the following line of code above the first Sub statement
in a module

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

Then in the same module, include the following routine

Public Sub OpenAcrobatFile(strFile As String)
ShellExecute 0, "open", strFile, vbNullString, vbNullString, 9
End Sub

Then simply call the routine, passing it the full pathname of the PDF file
you want to open.
 
G

Guest

Thanks Cindy,

We have 5 versions of Word (nightmare), the oldest being
97 and 2003 being the latest.
 

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