Link to home
Start Free TrialLog in
Avatar of tselectro
tselectro

asked on

Open PDF file and goto a specific page

Hello

From VBA in Excel 2007 I want to open a pdf file in Adobe Reader (outside Excel). That work ok. But when I try to use parameter to specify a page number, zoom etc. it does not do what I expect.

From shell the following work successful:
AcroRd32.exe /A "page=2,zoom=100"  "C:\Tmp\manual.pdf"

In VBA I use ShellExecute API function:
sParam = "/A " & Chr(34)  & "page=2,zoom=100" & Chr(34)
Call ShellExecute(0&, "Open", "c:\tmp\manual.pdf", sParam, vbNullString, SW_SHOWNORMAL)

It opens the pdf file, but ignores the parameters.

If I open the url "c:\tmp\manual.pdf#page=2&zoom=90" in Internet Explorer (use the Shell function in Excel), it work as expected.

My question is: How can I open a pdf file with parameters (page,zoom, nameddest etc) from Excel VBA?
Avatar of wobbled
wobbled
Flag of United Kingdom of Great Britain and Northern Ireland image

From a quick search around I believe this can be done:  I found this code on another Experts Call that covers what you wish to do.  If this fails but it works in an browser why don't you use the browser option - shell command it to open it and then give it the URL?


https://www.experts-exchange.com/questions/20949436/Open-a-PDF-document-and-goto-specific-page.html

Dim AVDoc As Acrobat.CAcroAVDoc
Dim AVPageView As Acrobat.CAcroAVPageView
Dim AcroApp As Acrobat.CAcroApp
 
Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")

AVDoc.Open(URL, "")

Set AVPageView = AVDoc.GetAVPageView
AVPageView.Goto(4)
ASKER CERTIFIED SOLUTION
Avatar of tselectro
tselectro

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial