Automatically Open Specific Page in PDF Document Using Excel VBA

Many viewers wanted to know how to automatically open a specific page in a PDF document using Excel VBA. Watch the training video below before you study the complete VBA code and download the attached sample file:


Watch the video on YouTube.


Download a sample Excel file:


Complete VBA code for automatically opening a specific page number in a PDF document in Excel:
Sub openPDFPage()
Dim myLink As String
Dim myPage As Long
Dim objIE As New InternetExplorer

‘myLink = “C:\files-from-excelvbaonline\excel_vba_programming_for_dummies_3rd_edition.pdf”
myLink = “http://www.excelvbatutor.com/vba_book/vbabook_ed2.pdf”

myPage = InputBox(“Enter the page number”)

With objIE
.Navigate myLink & “#page=” & myPage
.Visible = True
End With
End Sub

Published by

Dinesh Kumar Takyar

Welcome to exceltrainingvideos.com! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: http://youtube.com/familycomputerclub For a structured Excel VBA training course online you can visit: https://www.youtube.com/excelvbaonline

4 thoughts on “Automatically Open Specific Page in PDF Document Using Excel VBA”

  1. I enjoyed your video on how to convert excel to PDF file, and have it sent automatically. But how can I get selected area converted in the worksheet say “page-one”, “page-two” etc instead of the whole sheet?

  2. Hi Sir
    I have a list of the lecture notes and one pdf file that contain all the lecture notes in different page . I’ve used your recommendation and have assigned a macro to a button with this codes:

    Sub openPDFPage()
    Dim myLink As String
    Dim myPage As Long
    Dim objIE As New InternetExplorer

    myLink = “E:\Exam\MCCEE\internal.pdf”
    myPage = InputBox(“Enter the page number”)

    With objIE
    .Navigate myLink & “#page=” & myPage
    .Visible = True
    End With
    End Sub

    but after running the macro, Internet explorer opens the first page of my PDF file , not the page that I input there .
    I tried this format : E:\Exam\MCCEE\internal.pdf#page=23

    in the address bar of the Internet Explorer directly and it worked .
    of course after interring the address I have to refresh the address to go to my desire page (23)
    I need your Comment please.
    thank you very much

  3. Hi , I have a vba code to display pdf file in the web browser control when we click or select link from the listbox, its working fine with my pc but on another PC its automatically opening in “pdf adobe reader” instead of web browser. how can i change this to web browser? i cannot find the reason of this, please help!!

    Private Sub ListBox1_Click()
    Application.DisplayAlerts = False
    Application.ScreenUpdating = False
    On Error Resume Next
    Dim AA1, AA2 As Variant
    AA1 = UserForm6.Frame1.ListBox1.Text
    AA2 = “C:\PO_Pfile\Temp1\Temp12.pdf”
    FileCopy AA1, AA2

    WebBrowser1.Navigate (AA1)
    Workbooks(“PO_SFile”).Sheets(“Sheet2”).Range(“AP2”) = AA1

    End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *