• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

AvDoc FindText returning to first page.

Community Beginner ,
Jan 24, 2019 Jan 24, 2019

Copy link to clipboard

Copied

Hi,

I am attempting to implement AVDoc.FindText in an excel VBA script to find and highlight all instances of a search term in a document.  Here is the code I have:

Dim AcroApp, AcroAVDoc

    Dim gPDFPath, bReset, nCount

    gPDFPath = "PATH TO FILE"

    ' ** Initialize Acrobat by creating App object

    Set AcroApp = CreateObject("AcroExch.App")

    ' ** show Acrobat

    Call AcroApp.Show

    ' ** Set AVDoc object

    Set AcroAVDoc = CreateObject("AcroExch.AVDoc")

    ' ** open the PDF

    If AcroAVDoc.Open(gPDFPath, "") Then

    Call AcroAVDoc.BringToFront

    bReset = True: nCount = 0

    Do While AcroAVDoc.FindText("Text to Find", True, True, bReset)

         bReset = False: nCount = nCount + 1

    Loop

...

End Sub

But the problem is that the Do While Loop does not seem to resolve itself.  Once the FindText function finds the last instance of text in the document, it then finds the next instance, on Page one.  This of course causes that while loop to never terminate.

Anyone know what my issue could be, am I interpreting incorrectly how BReset should be working?

Adobe 2017 Pro (2017.011.30110)

Excel 2010

TOPICS
Acrobat SDK and JavaScript

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 24, 2019 Jan 24, 2019

Copy link to clipboard

Copied

LATEST

The documentation is silent on whether searches without bReset TRUE should wrap. You assume/wish it wouldn't, but I guess it might, so you can check if it goes backwards and terminate in that case.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines