Article View: adobe.scripting.indesign
Article #18050Re: Replace text
From: roberto soto
Date: Fri, 25 Apr 2003 18:04
Date: Fri, 25 Apr 2003 18:04
55 lines
2644 bytes
2644 bytes
I used XML tag, for auto pricing items inside pages from SQL server.
In your case you have a Text Frame with
'bla bla bla bla DATE bla bla bla'
so you need to tag this text frame and after tag the word "DATE"
doing this you can change after any word inside this tag
for one or more words and tag remain for future use even after
user "save"
This is the "GLOBAL IDEA" you need to tuning
for your needs
I hope this code will be usefull
Roberto
Private Sub Command1_Click()
Dim myXMLStory As InDesign.XMLElement
Dim myXMLDate As InDesign.XMLElement
Dim myXMLStoryTag As InDesign.XMLTag
Dim myXMLDateTag As InDesign.XMLTag
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set myDocument = myInDesign.Documents.Add
Set myTextFrame = myDocument.TextFrames.Add
myTextFrame.GeometricBounds = Array(5, 4, 18, 22)
myTextFrame.TextContents = "bla bla bla DATE bla bla"
Set myXMLStoryTag = myDocument.XMLTags.Add("TextFrame1")
Set myXMLStory = myDocument.XMLElements.Add(myXMLStoryTag, myTextFrame)
Set myStory = myTextFrame.ParentStory
Set myWord = myStory.Search("DATE")
myTag = "Tag1"
Set myXMLDateTag = myDocument.XMLTags.Add(myTag)
Set myXMLDate = myXMLStory.XMLElements.Add(myXMLDateTag, myWord.Item(1))
'Here you will have the Text Frame, with some text and word "DATE" marked with a tag
'You can see all of this clicking CTR+ALT+1 (you need the last version InDesign 2.0.2)
'Click view - show tag markers (to see the tag in the text)
'Click window - tags (to see the windows tag markers)
'Now you can use this tag and record information from the database to update the information
'UNCOMMENT TO USE
' Set myElement = myDocument.XMLElements.Item(1)
' Set myTagElement = myElement.XMLElements.Item(1)
'
' myTagElement.AssociatedObject.TextContents = "HELLO INDESING"
End Sub
Technical Details
Message-ID:
<1de8debf.4@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de8debf.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,8dc374c09771dee6 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-04-25 11:07:50 PST From: "roberto soto" <roberto1soto@hotmail.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Replace text Message-ID: <1de8debf.4@WebX.la2eafNXanI> Date: Fri, 25 Apr 2003 11:04:45 -0700 References: <1de8debf.-1@WebX.la2eafNXanI> Lines: 60 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit