Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Opening a PDF from Excel

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Opening a PDF from Excel

You can try this

ActiveWorkbook.FollowHyperlink "C:\Test.pdf"



--
Regards Ron de Bruin
http://www.rondebruin.nl


wrote in message ups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Opening a PDF from Excel

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


Scott

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Opening a PDF from Excel

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
wrote in message
ups.com...
| That works. Thanks.
| The only annoyance is the warning about hyperlinks being harmful but
| other than that success.
|
|
| Scott
|


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Opening a PDF from Excel

Hi Jim

Can you look at
Printing -- Page Number Continuity

Thanks


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim Rech" wrote in message ...
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
wrote in message
ups.com...
| That works. Thanks.
| The only annoyance is the warning about hyperlinks being harmful but
| other than that success.
|
|
| Scott
|






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Opening a PDF from Excel

Sure

--
Jim
"Ron de Bruin" wrote in message
...
| Hi Jim
|
| Can you look at
| Printing -- Page Number Continuity
|
| Thanks
|
|
| --
| Regards Ron de Bruin
| http://www.rondebruin.nl
|
|
| "Jim Rech" wrote in message
...
| 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
| wrote in message
| ups.com...
| | That works. Thanks.
| | The only annoyance is the warning about hyperlinks being harmful but
| | other than that success.
| |
| |
| | Scott
| |
|
|
|
|


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I stop blank workbook from opening when opening an existing kjg Excel Discussion (Misc queries) 3 February 12th 10 09:36 PM
Opening files in Excel 2003 saved in Excel 2000 without data loss... [email protected] Excel Discussion (Misc queries) 0 January 29th 07 07:19 PM
Trouble opening large size Excel file 155Mb in Excel 2007 pl2c Excel Discussion (Misc queries) 2 July 14th 06 11:45 PM
REF errors when opening excel in xp. works fine when opening wor. br Excel Discussion (Misc queries) 6 September 13th 05 11:41 AM
excel VBA problem - setting workbook as variable & opening/re-opening safe Excel Programming 1 August 20th 04 12:22 AM


All times are GMT +1. The time now is 10:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"