🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15206

[VB] Can't get this script to run under CS

#15206
From: Perrin_Kliot
Date: Fri, 12 Dec 2003 00:18
61 lines
3849 bytes
I came across a demo script that Ole wrote a while ago and it works great under 2.0 but I can't figure out what
I need to change to get it to run under CS, I'm using Windows and VBScript.

The Set myFoundTag = .. doesn't seem to be getting set correctly but I'm not sure why not.

Any help would be GREATLY appreciated.
Perrin

Rem PlaceGraphicAtTag
Rem An InDesign 2.x script.
Rem Places a graphic at locations in text defined by begin "<<" and end ">>" tags.
Rem Optional variable declarations. Omit these if you are creating a VBScript.
rem Dim myInDesign As InDesign.Application
rem Dim myPath As String
rem Dim myDocument As InDesign.Document
rem Dim myStory As InDesign.Story
rem Dim myStartItems, myEndItems, myFoundTag As Object
rem Dim myCounter, myFoundCounter, myStartIndex, myEndIndex As Long
Rem Enter the path to the folder containing the images you want to place.
Rem (Include the trailing backslash "\".)
myPath = "i:\image\catalog\"
Set myInDesign = CreateObject("InDesign.application.2.0")
Rem Clear the find/change preferences.
rem myInDesign.FindPreferences = idNothing
rem myInDesign.ChangePreferences = idNothing
Set myDocument = myInDesign.ActiveDocument
Rem Work through the document story-by-story.
For myCounter = 1 To myDocument.Stories.Count
    Set myStory = myDocument.Stories.Item(myCounter)
    Rem Create an object containing references to all instances of
    Rem the "start tag" string ("<<" in this example).
    Set myStartItems = myStory.Search("<<")
    If myStartItems.Count > 0 Then
        Rem Create an object containing references to all instances of
        Rem the "end tag" string (">>" in this example).
        Set myEndItems = myStory.Search(">>")
        If myStartItems.Count = myEndItems.Count Then
            Rem Iterate through the found items backwards to avoid invalidating
            Rem text object references preceding them in the story.
            For myFoundItemCounter = myStartItems.Count To 1 Step -1
                Set myStartItem = myStartItems.Item(myFoundItemCounter)
                myStartIndex = myStartItem.Characters.Item(1).Index
                Rem Get the corresponding "end" tag.
                Set myEndItem = myEndItems.Item(myFoundItemCounter)
                myEndIndex = myEndItem.Characters.Item(-1).Index
                Rem Get a reference to the first character in the "start" tag.
                Set myStartCharacter = myStory.Characters.Item(myStartIndex)
                Rem Get a reference to the first character in the "end" tag.
                Set myEndCharacter = myStory.Characters.Item(myEndIndex)
                Rem Use the ItemByRange method to get a reference to the entire tag.
                Set myFoundTag = myStory.Characters.ItemByRange(myStartCharacter, myEndCharacter).Item(1)
                Rem Replace the text of the tag with the specified graphic.
                myFoundTag.Texts.Item(1).Place myPath & Mid(myFoundTag.TextContents, 3, Len(myFoundTag.TextContents) - 4)
            Next
        Else
            Rem We have a mismatched tag somewhere.
            MsgBox "One of the stories contains a mismatched tag."
            Exit For
        End If
    End If
Next
Technical Details
Message-ID: <2ccee2ce.-1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,280e03cf7e7d0528,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-12-11 16:37:54 PST
From: Perrin_Kliot@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: [VB] Can't get this script to run under CS
Message-ID: <2ccee2ce.-1@webx.la2eafNXanI>
Date: Thu, 11 Dec 2003 16:18:11 -0800
Lines: 77
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit