Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Start PDF Document on specific page via VBScript with variable pagenumber

Status
Not open for further replies.

Cowboy91

Technical User
Mar 6, 2013
2
DE
Hi

I'm trying to open a pdf document via vbscript. This is what I have got so far:

Code:
	Dim wshShell, Page, temp
	
	Page = 2
	
	temp = Replace("""""""C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"""" /A """"page=""""  
                       """"C:\Doc.pdf""""""","page=","page="&Page)
	
	Set wshShell = CreateObject("WSCript.shell")
	wshShell.Run temp
	Set wshShell = Nothing

The result of the Replace-function is:
"""C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"" /A ""page=2"" ""C:\Doc.pdf"""

This string is necessary to open a PDF on specific page via vbscript.
The problem is, the command
Code:
wshShell.Run temp
just opens the Windows Explorer... but no pdf. If I write straight
Code:
 wshShell.Run """C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"" /A ""page=2"" ""C:\Doc.pdf"""
then it works... but I want the initial page of the pdf to be read from a variable (here: "Page"), not as a constant.

I also tried a concatenation:
Code:
wshShell.Run """C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"" /A ""page="" & Page & ""C:\Doc.pdf"""
but neither this works, no matter how you look at it...

I'd appreciate any help
 
1) Why not just:
Code:
temp = """C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"" /A ""page=" & Page & """ ""C:\Doc.pdf"""

2) This is not really ASP, so you may be better off in the vbscript forum here: forum329

 
Thank you very much guitarzan!!

Your version of concatenation works =). I just didn't know where to put all the quotation marks and how many... but yours really works.

Besides:
I didn't notice that I'm in the wrong forum for I'm new in this forum^^.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top