locked
macro to open file in other page RRS feed

  • Question

  • I write:

     Dim myShell As Object
    Set myShell = CreateObject("WScript.Shell")
    myShell.Run "C:\myfile.pdf"

    I want the file open in page 3.

    How am I do it?

    • Edited by hila_d Tuesday, April 17, 2012 1:43 PM
    Tuesday, April 17, 2012 9:32 AM

Answers

  • Hi Hila_d,

    Thank you for posting.

    Please try the following code snippet:

    Sub test()
    pat1 = """C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"""

    pat2 = "/A ""page=3"""

    pat3 = """C:\Users\v-bpeng\Desktop\1.pdf"""

    Shell pat1 & " " & pat2 & " " & pat3, vbNormalFocus
    End Sub

    Hope this can help you and just feel free to follow up after you have tried.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by hila_d Sunday, April 22, 2012 9:13 AM
    Thursday, April 19, 2012 6:49 AM

All replies

  • Hi Hila_d,

    Thank you for posting.

    Please try the following code snippet:

    Sub test()
    pat1 = """C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"""

    pat2 = "/A ""page=3"""

    pat3 = """C:\Users\v-bpeng\Desktop\1.pdf"""

    Shell pat1 & " " & pat2 & " " & pat3, vbNormalFocus
    End Sub

    Hope this can help you and just feel free to follow up after you have tried.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by hila_d Sunday, April 22, 2012 9:13 AM
    Thursday, April 19, 2012 6:49 AM
  • what is define of variable pat1,pat2,pat3? string?
    Thursday, April 19, 2012 6:58 AM
  • Yes, they can be defined as string.

    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us


    • Edited by Bruce Song Monday, April 23, 2012 2:24 AM
    Monday, April 23, 2012 2:24 AM
  • Can I have another option that not call shell to open pdf file at specific page?

    Use at AcroApp or AcroAVDoc?

    Wednesday, May 2, 2012 6:20 AM
  • I want write macro in word, to  open other word file in other page (not page 1).

    How am I do it?

    • Edited by hila_d Tuesday, May 8, 2012 8:40 AM
    Tuesday, May 8, 2012 8:39 AM
  • But YOU used Shell in your original post.

    Word MVP

    Friday, May 11, 2012 6:39 PM
  • Another Word file???  In your original post you used a PDF.  Please try and post what you actually want.

    This would be very easy to use the macro recorder to figure out.  Please try recording a macro, and if you have problems post your code and tell us what does not work.  Try recording a macro opening the fiule, then moving the Selection to the page you want.  That will be your code.


    Word MVP

    Friday, May 11, 2012 6:42 PM