Copy link to clipboard
Copied
Hello everyone! Not sure what I am doing wrong here, and I am having trouble finding examples of this online, so I thought I would ask.
var docRef = app.activeDocument;
var textRef = docRef.textFrames;
var paraStyle = docRef.paragraphStyles.getByName ("LeftIndent");
var iCount = textRef.paragraphs.length; //This is the error that shows up.
for(var i=0; i<iCount; i++) {
paraStyle.applyTo(textRef.paragraphs, true);
}
redraw();
Thanks in advance!!
‌at a glance I would say you need to loop textframes and within that loop paragraphs.
Copy link to clipboard
Copied
‌at a glance I would say you need to loop textframes and within that loop paragraphs.
Copy link to clipboard
Copied
Thanks imagecollection, I almost have it figured out now. I still get an error every so often. I am just making random text boxes with random type in it, and sometimes I will get an error. I have no idea why the particular text box makes it have an error, when I delete it the error goes away, I am not doing anything different to it that I know of.
var docRef = app.activeDocument;
var textRef = docRef.textFrames;
var paraStyle = docRef.paragraphStyles.getByName ("LeftIndent");
for(var i=0; i<textRef.length; i++) {
for(var j = 0; j < textRef.paragraphs.length; j++) {
paraStyle.applyTo(textRef.paragraphs
}
}
redraw();
Copy link to clipboard
Copied
Thanks again for getting me on the right track. This seems to work for me.
var docRef = app.activeDocument;
var textRef = docRef.textFrames;
var paraStyle = docRef.paragraphStyles.getByName ("ENERGETIC");
//in the dialog box make a custom option that will by pass the paragraph styles
paraStyle.characterColor = docRef.swatches[2];
for(var i=textRef.length-1; i >= 0; i--) {
try {
paraStyle.applyTo(textRef.paragraphs[0], true);
textRef.createOutline()
}
catch (e) {
textRef.remove()
}
}
//worry about the color after the outines have been created. Then it will be a group item.
redraw();
In my template file I use for this I have it set up as a bunch of 1 line story connected text boxes so I only have 1 paragraph in each. Now with this script I can copy and paste an excel spreadsheet of names, and each name will be individually grouped and that will be super helpful.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now