Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placing text with linked graphics

Status
Not open for further replies.

skrudrajver

Technical User
Jul 12, 2004
2
SI
When using PM6.5 I had no problems importing tagged texts containing links to the graphics I wanted within my text. Style name would be "PICT", the path would place/link the desired image where it was supposed to be in the layout.

<@PICT:><&48mm 21mm 0 "\\Data\a01.tif">

Trying to do the same in InDesign CS I simply can't find the proper code to do the same. I tried a lot of possible linking options and strings, but nothing works. So, please, if anyone has an idea or an example of such text, help me.

Thanks.
 
skrudrajver,

What OS are you using, I have a VbScript that does what you want to do. I use it to import graphics into my print catalog. It's a VbScript so it will only work under Windows. I'll post the code below. If you are using Mac let me know I may have a javascript version. The credit for this script goes to Olav at Adobe.

Code:
Rem PlaceGraphicAtTag.vbs 
Rem An InDesign CS script. 
Rem Places a graphic at locations in text defined by begin "[~" and end "~]" tags such as [~c:\graphic.jpg~]. 
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.CS") 
Rem Clear the find/change preferences. 
myInDesign.FindPreferences = idNothingEnum.idNothing 
myInDesign.ChangePreferences = idNothingEnum.idNothing 
Set myDocument = myInDesign.ActiveDocument 
myDocument.save("i:\doc\catalog\Descriptive Catalog.indd")
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.Texts.ItemByRange(myStartCharacter, myEndCharacter).Item(1) 
                Rem Replace the text of the tag with the specified graphic. 
                myFileName = Mid(myFoundTag.Contents, 3, Len(myFoundTag.Contents) - 4) 
                myFoundTag.Place myPath & myFileName 
Rem	myFoundTag.item(1).fit idFitOptions.idCenter-Content
Rem              msgBox myFoundTag.contents
            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

msgBox  "Done Updating Graphics."
 
Thanks to both of you.

toRobiNet:
I found your help very useful, but still need to do some editing. Fact of the matter is that I am working an add magazine layout, so importing graphics with text is much easier than placing them manually.

to Pliot:
I am using WinXP. Still getting to know InDesign scripting since the pm65 had completely different way of outting things together.

However, thanks again for your quick replies.

Skrudrajver
 
skrudrajver,

I don't understand you :(

to use my script, you need to mark file_names with CharStyle & run script ...

what you mean "so importing graphics with text is much easier than placing them manually" ??

robin

Scripts for InDesign
gg 3753393
Skype: indesignscripts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top