Solved

Open PDF file and goto a specific page

Posted on 2008-10-28
2
2,687 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:tselectro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Expert Comment

by:wobbled
ID: 22820285
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?


http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_20949436.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)
0
 

Accepted Solution

by:
tselectro earned 0 total points
ID: 22822584
Hello

I get error 429 in VBA when trying your solution (ActiveX component can't create object).

I have do some experiment with the ShellExecute and have find one solution. Following code do what I want:

sParam = " /A " & Chr(34) & "page=1&zoom=100&pagemode=bookmarks" & Chr(34) & "C:\tmp\manual.pdf"
 
Call ShellExecute(0&, "open", "AcroRd32.exe", sParam, "", SW_SHOWNORMAL)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question