start with the book 'Adobe Intro to Scripting', follow the samples, don't copy and paste, retype everything, it'll stick easier that way.
for this example, make two text frames (type anything it won't matter), give them names, 'firstName' and 'lastName'. The script will prompt you for text, look for those text frames and replace their content with the provided text.
var idoc = app.activeDocument; var title = 'Invoice Helper'; var first = prompt ('Enter First Name', 'Mickey', title); var last = prompt ('Enter Last Name', 'Mouse', title); // make sure you have two text frames named 'firstName' and 'lastName' var frameFirst = idoc.textFrames.getByName ('firstName'); var frameLast = idoc.textFrames.getByName ('lastName'); frameFirst.contents = first; frameLast.contents = last;
make two text frames (type anything it won't matter), give them names
Concerning this, when you type text in a text frame the name defaults to the text. However when you try to retrieve the name property you get nothing, until you go in and replace what is there with the same or something else. Just curious Carlos but do you know why it can't gather the text that is already applied to the name from the text data without replacing it even if it is the same data used to replace it?
the text you see in the layers panel is a ''preview" of the frame's content, not the actual textFrame's name. TextFrames need to be explicitly named just like paths, groups, etc
Hi CarlosCanto thanks for responding. This is what I was referring to as described in post #2 (CS5.x). I typed "some text" on the page, the layers panel yes shows this as the preview for the item, but this data also resides in the name option. Yet until you cut and paste or retype the name back into the name option (after first making a change and closing the window, then reopening) it can not be retrieved. It just seemed odd that actual data is there originally but can't however be referenced via scripting concerning textframes and the name property.
It just seemed odd
it is odd