Opening a PDF from Excel

B

brotherescott

I am trying to open a PDF from Excel VBA. I do not want to specify the
full path to "AcroRd32.exe" as it may be installed in different
locations on different PC's. I found the following code from Tom Ogilvy
but when I run it I get a file not found error. I know the file exists.
I can browse to it and double click it to open it. I want the
"Test.pdf" file to open with what ever program is associated with a
..PDF in windows.
I do not want to specify the program to use to open the file.

Sub OpenPDF()
Shell "Start.exe ""C:\temp\Test.pdf"""
End Sub
--
Regards,
Tom Ogilvy

I am running windows XP

Thanks
Scott Riddle
 
B

brotherescott

That works. Thanks.
The only annoyance is the warning about hyperlinks being harmful but
other than that success.


Scott
 
J

Jim Rech

Another way:

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

Sub LaunchPDF()
ShellExecute 0, "Open", "c:\File.pdf", "", "", 1
End Sub


--
Jim
| That works. Thanks.
| The only annoyance is the warning about hyperlinks being harmful but
| other than that success.
|
|
| Scott
|
 
J

Jim Rech

Sure

--
Jim
| Hi Jim
|
| Can you look at
| Re: Printing -- Page Number Continuity
|
| Thanks
|
|
| --
| Regards Ron de Bruin
| http://www.rondebruin.nl
|
|
| > Another way:
| >
| > 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
| >
| > Sub LaunchPDF()
| > ShellExecute 0, "Open", "c:\File.pdf", "", "", 1
| > End Sub
| >
| >
| > --
| > Jim
| > | > | That works. Thanks.
| > | The only annoyance is the warning about hyperlinks being harmful but
| > | other than that success.
| > |
| > |
| > | Scott
| > |
| >
| >
|
|
 

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