INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Start PDF Document on specific page via VBScript with variable pagenumber

Start PDF Document on specific page via VBScript with variable pagenumber

Start PDF Document on specific page via VBScript with variable pagenumber

(OP)
Hi

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

CODE --> VBScript

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 --> VBScript

wshShell.Run temp 
just opens the Windows Explorer... but no pdf. If I write straight

CODE --> VBScript

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 --> VBScript

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

RE: Start PDF Document on specific page via VBScript with variable pagenumber

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: VBScript

RE: Start PDF Document on specific page via VBScript with variable pagenumber

(OP)
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^^.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close