Article View: adobe.scripting.indesign
Article #19314Re: Please, help with find and replace within a specific object (Text Frame?).
From: Olav Kvern
Date: Fri, 20 Dec 2002 20:21
Date: Fri, 20 Dec 2002 20:21
52 lines
3210 bytes
3210 bytes
iolaire--
If it contains text, it's a TextFrame. You might want to change the variable name to "myTextFrame," rather than "myImage," just to keep things from getting confusing.
I think that the problem, though, is with the reference. Is it possible that you have more than one text frame on the page named "Left_Header", or that "Left_Header" appears on a master page and not on the document page? Try the example below:
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application")
Rem Clear the application's Find/Change preferences
myInDesign.FindPreferences = idNothing
myInDesign.ChangePreferences = idNothing
Rem Create an example document.
Set myDocument = myInDesign.Documents.Add
Rem Create a color to use in an example character style
Set myColor = myDocument.Colors.Add
myColor.Model = idProcessColor
myColor.ColorValue = Array(100, 0, 40, 0)
Rem Create an example character style.
Set myCharStyle = myDocument.CharStyles.Add
myCharStyle.FillColor = myColor
Set myPage = myDocument.Pages.Item(1)
Set myTextFrame = myPage.TextFrames.Add
myTextFrame.GeometricBounds = Array("6p", "6p", "18p", "32p")
myTextFrame.TextContents = "WASHINGTON, D.C." & vbTab & "December 20, 2002"
myTextFrame.Label = "LEFT_HEADER"
Rem Create another text frame with some content similar to the first frame.
Set myTextFrame = myPage.TextFrames.Add
myTextFrame.GeometricBounds = Array("18p", "6p", "24p", "32p")
myTextFrame.TextContents = "Not affected by find/change: WASHINGTON, D.C." & vbCr & "Affected by find/change: "
myTextFrame.InsertionPoints.Item(-1).CharacterStyle = myCharStyle
myTextFrame.InsertionPoints.Item(-1).TextContents = "WASHINGTON, D.C."
myTextFrame.Label = "Body_Text"
Rem Get a reference to the first text frame using the frame's label.
Set myTextFrame = myPage.TextFrames.Item("LEFT_HEADER")
myTextFrame.Search "WASHINGTON, D.C.", False, False, "CHICAGO"
Rem Get a reference to the second text frame using the frame's label.
Set myTextFrame = myPage.TextFrames.Item("Body_Text")
Rem Set the find format to the example character style.
myInDesign.FindPreferences.CharacterStyle = myCharStyle
Rem Find and change the text using the current find attributes.
myTextFrame.Search "WASHINGTON, D.C.", False, False, "CHICAGO"
Does that work for you?
Thanks,
Ole
Technical Details
Message-ID:
<1de71592.0@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de71592.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,88594b52b8ecdcde X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-12-20 12:38:30 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Please, help with find and replace within a specific object (Text Frame?). Message-ID: <1de71592.0@WebX.la2eafNXanI> Date: Fri, 20 Dec 2002 12:21:36 -0800 References: <1de71592.-1@WebX.la2eafNXanI> Lines: 56 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit