Santo
Santo

Reputation: 41

How to assign a macro in a Word Document to open a PDF to specific page

I am trying to assign a macro with commandbutton in a Word document which when clicked should open a PDF document of page 9. I trying with the below Code but not successful in solving my Problem.

I am adding the below Code in 'Module 1'.

Private Sub CommandButton1_Click()
    App_Path = "C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe"
    File_Path = "C:\Users\Desktop\USER MANUAL.pdf"
    Page_Num = 4
    Shell App_Path & " /A Page=" & Page_Num & "" & File_Path, vbMaximizedFocus
End Sub

Upvotes: 0

Views: 177

Answers (1)

Pᴇʜ
Pᴇʜ

Reputation: 57753

Because your paths contain spaces both paths need to be enclosed in quotes ""

App_Path = """C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe"""
File_Path = """C:\Users\Desktop\USER MANUAL.pdf"""

Also there needs to be a space between Page_Num and File_Path so replace & "" & with & " " &.

Shell App_Path & " /A Page=" & Page_Num & " " & File_Path, vbMaximizedFocus

Upvotes: 1

Related Questions