Skip to main content
j.khakase
Inspiring
February 19, 2024
Answered

Looking Illustrator script: To write Document title at selected text frame

  • February 19, 2024
  • 1 reply
  • 1161 views

Dear Friends,

Looking a script to write document title at my prepared and selected text frame. this will be great help on creating multiple documents from the template. 

I browse on net getting many script to write doc title at various position. but I am expecting it at my selected/prepared text-frame

below is the screenshot

 

This topic has been closed for replies.
Correct answer Kurt Gold

As for the selection issue, you may take this instead.

 

function dt() {

var doc = app.activeDocument;
var documentTitle = doc.name.split('.')[0];

for (var i = 0; i < doc.textFrames.length; i++) {
var textFrame = doc.textFrames[i];

if (textFrame.selected) {
if (textFrame.kind === TextType.POINTTEXT || textFrame.kind === TextType.AREATEXT) {
textFrame.contents = documentTitle;
}
}
}
}

dt();

1 reply

Kurt Gold
Community Expert
Community Expert
February 19, 2024

You may try this.

 

function dt() {
var doc = app.activeDocument;
var documentTitle = doc.name.split('.')[0];
    
for (var i = 0; i < doc.textFrames.length; i++) {
var textFrame = doc.textFrames[i];
        
if (textFrame.kind === TextType.POINTTEXT || textFrame.kind === TextType.AREATEXT) {
textFrame.contents = documentTitle;
}
}
}

dt();
j.khakase
j.khakaseAuthor
Inspiring
February 20, 2024

Thank you so much, Its working perfectly as I want. saved many clicks