Article View: adobe.scripting.indesign
Article #1363Using Grep to find text pattern, get found text, and get page number found on
From: Ric_Miller
Date: Wed, 11 Feb 2009 20:14
Date: Wed, 11 Feb 2009 20:14
32 lines
1699 bytes
1699 bytes
Hi there,
I have been successful in finding text using grep and returning the text, but need to identify what page the text is on.
This example finds an email address. So far I have:
Set myInDesign = CreateObject("InDesign.Application.CS3")
Rem Clear the find/change preferences.
myInDesign.FindGrepPreferences = idNothingEnum.idNothing
myInDesign.ChangeGrepPreferences = idNothingEnum.idNothing
Rem Set the find options.
myInDesign.FindChangeGrepOptions.IncludeFootnotes = False
myInDesign.FindChangeGrepOptions.IncludeHiddenLayers = False
myInDesign.FindChangeGrepOptions.IncludeLockedLayersForFind = False
myInDesign.FindChangeGrepOptions.IncludeLockedStoriesForFind = False
myInDesign.FindChangeGrepOptions.IncludeMasterPages = False
Rem Regular expression for finding an email address.
myInDesign.FindGrepPreferences.FindWhat = "(?i)[A-Z]*?@[A-Z]*?[.]..."
Set t = myInDesign.FindGrep
For i = 1 to t.Count
Debug.Print t.Item(i).Contents
' How do I get the page number that the text was found on?
Next
Can anyone help with this?
Thanks,
Ric
Technical Details
Message-ID:
<59b7e2c7.-1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news2.glorb.com!newshub.sdsu.edu!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f939a,c068c4e91c9ba325,start X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Ric_Miller@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news2.glorb.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Using Grep to find text pattern, get found text, and get page number found on Message-ID: <59b7e2c7.-1@webcrossing.la2eafNXanI> Date: Wed, 11 Feb 2009 12:14:13 -0800 Lines: 33 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit