Indesign CS3 - text into text frame

Hi
what I’m trying to do is: I’ve created a template with a text frame in it, I named it with a ScriptLabel. What I want to do is open the template and insert some text from a variable into that text frame.

I can get it to do it no problem if I create a new text frame I don’t know how to insert it into the existing labelled text frame

If anyone has any ideas it’d be greatly appreciated!!

Hi,

something like this

tell application "Adobe InDesign CS3"
	make new document
	tell document 1
		tell page 1
			set theMainText to make text frame with properties {geometric bounds:{12.5, 12.5, 50, 50}}
		end tell
		set contents of theMainText to ("This is a test" & return)
	end tell
end tell

Take a look at Adobe InDesign CS3 Scripting Guide: AppleScript

thanks for your reply but I can already do that - I’ll be a bit more specific:

  • I have an Indesign template file (stamp.indt) which has a text frame in it. I’ve selected the text frame and added the name called “MyTextFrame” in the Script Labels panel
  • the script runs and extracts some data from FileMaker Pro
  • the script the opens the Indesign template stamp.indt and inserts the data from FileMaker into the existing text frame called “MyTextFrame”.
    I don’t want to create the text frame when I insert the text - I want to insert it into and existing named text frame as I have a number of text frames I want to insert the data into. I’ve looked in the Indesign scripting guide but it doesn’t seem to tell you how to do this. I’m not having any problems doing the stuff in your solution, it’s just not the way I want to do it.
    thanks

You should be able to just set the contents by calling your text frame:

tell application "Adobe InDesign CS2"
	set contents of text frame "MyTextFrame" of page 1 of document 1 to ("This is a test" & return)
end tell

Now, if the text frame is on a master page and has not been over ridden then you will have to over ride the text frame from the master page before you address is. Untill you do that it is really not “on” the page so you cannot target it with the script.

thanks for that - that’s pretty much what I thought, but what do you mean by “over ride the text frame”?
thanks

If the text frame is placed on a master page then it is not technically on the page unless you override the master page item. To show this make a master page with a page item on it and make a call to a page with that master page applied to it to get every page item. If nothing else has been placed on the page other than the applied master page then the call will not return any page items.

I understand what you are saying but I still don’t have any idea how you “over ride” the master page item - does this mean you basically have to use:

set myTextFrame to make text frame
			set geometric bounds of myTextFrame to {40, 72, 96, 200}
etc etc
set the contents of myTextFrame to "The client is: " & ClientName & return & "The publication date is: " & PubDateFormatted & return & "The ad size is: " & PubSizeIndesign

for it to work?
thanks

Here’s an example of how you could override master page items:


tell application "Adobe InDesign CS3"
	tell document 1
		--makes a list of all master page items on a specific page
		set MasterPageItems to master page items of page pageNum
		--loops thru the list of items, unlocking any that have assigned script labels (label name is not blank)
		repeat with itemID from 1 to count of MasterPageItems
			if label of (item itemID of myMasterPageItems) is not "" then
				--this is the override command:
				override (item itemID of MasterPageItems) destination page page pageNum
			end if
		end repeat
	end tell
end tell

Mark

Thanks for your suggestions - I’ve decided it’s easier to create the text frames on the fly in this case
cheers