tags:

views:

50

answers:

1

I have an application that manages multiple magazine PDFs on the hard drive. I need to open the PDF files into a specific page. I am able to call vbscript from my own software so I am looking for some vbscript snippet to open a PDF with a specific page loaded. I am a mac developer doing cross platform software, windows is not my standard bread and butter.

From the Adobe docs, I checked that using system calls to open a URL like:

http://myserver/mypdf#page=3

works fine but trying to use similar URL with the dummy file protocol like:

file://path/to/mypdf#page=2

does not work. After figuring that, I decided that I should try some vbscript call to some COM or ActiveX or whatever they use these days on windows but I don't know how to do it.

Thanks for any help.

+1  A: 

You could use the "page=..." parameter of Acrobat Reader, like this:

Sub OpenPdf(filename, page)
   Set wshShell = WScript.CreateObject("WSCript.shell")
   wshShell.Run """%ProgramFiles%\Adobe\Reader 9.0\Reader\AcroRd32.exe"" /A ""page=" & _
      page & """ " & fileName
End Sub

OpenPdf "c:\temp\myfile.pdf", 20
fmunkert
thanks for the quick reply. Instead of hard coding the path to Reader 9.0 (I can't actually be sure if thats the version installed) is there a way to query the installed Reader path?
Andre Garzia
You could read the registry key `HKEY_CLASSES_ROOT\Applications\AcroRD32.exe\shell\Read\command` and extract the path to AcroRd32.exe from the registry key's standard value.http://www.activexperts.com/activmonitor/windowsmanagement/scripts/operatingsystem/registry/#RSDWORDRV.htm explains how to read the registry using VBScript.
fmunkert