Skip to main content
Participant
December 24, 2017
Question

How to use the PDBookMark object to navigate to the bookmarked page?I h

  • December 24, 2017
  • 2 replies
  • 3652 views

I have an Excel spreadsheet in which one column contains the bookmarks from several PDFs. For each bookmark, an adjoining cell contains a button with VBA code to open the corresponding PDA to the page specified by the book mark.  There are nearly 600 rows in the spreadsheet and more than two dozen associated PDFs.  While the underlying code is simple, it's very tedious to set  up and maintain.  I have been trying too make the code more general by using the PDDoc PDBookMark.Perform method.  Unfortunately I'm only able to open the desired PDF to page 1.  I don't understand the IAC documentation on how to set up and code this method.  Seems like I'm missing something.  Any assistance in helping to make this work will be greatly appreciated.  I'm using Acrobat Pro DC and have the Acrobat 10.0 TLB reference set .  Here's the code so far:

Sub Inpatient_170()
    Dim AVDoc As Acrobat.CAcroAVDoc
    Dim AVPageView As Acrobat.CAcroAVPageView
    Dim PDDoc As CAcroPDDoc
    Dim PDBookmark As AcroPDBookmark
    Dim strfile As String
    Dim myBookMark As String
    Dim rw As Integer

    'Get PDF path and file name  (this will eventually work like the bookmark selection below)
    strfile = "C:\Completed\Final - Edited - Inpatient Historical Records (2).pdf"

    'Grab the bookmark from the spreadsheet
    rw = ActiveCell.Row
    myBookMark = Worksheets("Sheet1").Range("C" & rw)
   
    Set AcroApp = CreateObject("AcroExch.App")
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    Set PDDoc = CreateObject("AcroExch.PDDoc")
    Set PDBookmark = CreateObject("AcroExch.PDBookmark")

    AVDoc.Open strfile, vbNull
    Set AVPageView = AVDoc.GetAVPageView
    AcroApp.Show
   
    Set PDDoc = AVDoc.GetPDDoc
    PDBookmark.GetByTitle PDDoc, myBookMark
    PDBookmark.Perform PDDoc
    Set avPageView = Nothing
    Set avDoc = Nothing

End Sub

This topic has been closed for replies.

2 replies

Legend
December 24, 2017

I find the documentation confusing because it suddenly talks about iDispatch.  Nevertheless, it mentioned AVDoc, so try an AVDoc, because you actually need to perform a bookmark in the context of a visible open document (AVDoc) not just an abstract open document (PDDoc). No, I haven't tried.

mikecottAuthor
Participant
December 25, 2017

Thank you again, Jive. I hate to admit I'm grasping at straws with this

Acrobat stuff. I tried replacing PDDoc with both AVDoc and AVPageView with

no difference in either case. There were no errors, but Acrobat stubbornly

remained on page 1. For now I will just fall back to the previous method

of specifying the target page number as in the attached example which

displays the proper page. Tried to paste it here, but it appears gmail

doesn't allow that.

On Sun, Dec 24, 2017 at 3:20 PM, Test Screen Name <forums_noreply@adobe.com>

try67
Community Expert
Community Expert
December 25, 2017

Jive is the name of the forums systems. The person replying to you is nicknamed "Test Screen Name"...

Legend
December 24, 2017

Your code seems to get the text from an Excel cell, find a PDF bookmark with that text, and go there. Do these bookmarks all exist in the PDF already, shown in the bookmarks pallete of Acrobat Pro?

Legend
December 24, 2017

Also: I observe that the Perform method requires an AVDoc not a PDDoc.

mikecottAuthor
Participant
December 24, 2017

Thank you for your response, Jive. Yes, the bookmarks all exist in their

respective PDF. The problem is the code won't cause the desired page to be

displayed in the Acrobat window. When I use the debugger to run this

code, the correct bookmark is in variable "myBookMark". But Acrobat

stubbornly remains on page 1. My weak understanding of the IAC is the

PDBookMark.Perform functionality belongs to PDDoc , not AVDoc. When you

type the line "PDBookMark.GetByTitle PDDoc, myBookMark" the VBA help popup

instructs to use pAcroPDDoc as Object where I have entered PDDoc. The

same hint appears on the next line. I'm not absolutely certain, but I

think that VBA hint means to use PDDoc.

On Sun, Dec 24, 2017 at 2:53 AM, Test Screen Name <forums_noreply@adobe.com>