Copy link to clipboard
Copied
Hello all,
i'm working on a large project with many files, i have to change edit on all Paragraph styles with multiple processes
for ex, change font for all Paragraph styles on all opened documents
var docs = app.documents;
for (var d = docs.length-1; d >= 0; d--) {
var doc=docs
;
var pstyles = doc.allParagraphStyles;
for (var a = 1; a < pstyles.length; a++) {
if (pstyles.appliedFont.name=="Arial\tBold")
pstyles.appliedFont = "Arial\tBold Italic";
}
}
but i found some text inside frames with (locked position) so my find/change didn't apply on it
so are there anyway to do this process to all locked position frame??
or at least do un lock to all opened documents but i only can do this for active doc
app.activeDocument.pageItems.everyItem().locked = false
another thing, i tried to edit on all Character styles on files and i wrote code with my little scripting knowledge but it seems not working, any hint please???
var docs = app.documents;
for (var d = docs.length-1; d >= 0; d--) {
var doc=docs
;
var cstyles = doc.allCharacterStyles;
for (var a = 1; a < cstyles.length; a++) {
if (cstyles.appliedFont.name=="Arial\tBold")
cstyles.appliedFont = "Arial\tBold Italic";
}
}
}
Thanks in advance
May be your text frame grouped.. try this
var docs = app.documents;
for (var d = docs.length-1; d >= 0; d--) {
var doc=docs
var pgItems = doc.allPageItems;
for (var a = 0; a < pgItems.length; a++) {
if(pgItems instanceof TextFrame){
while (doc.groups.length > 0)
doc.groups.everyItem().ungroup();
pgItems.locked = false; }
}
}
Copy link to clipboard
Copied
I can't see any reason why you couldn't change the font associated with a paragraphStyle whatever some text which style is applied to is locked or not. Unles you do find/replace texts and that in this case if you deactivated the search on locked items, then you can have thos kind of behaviours. But tweaking the style should n't be an issue.
A possible issue is that the texts have overrided styles so the look isn't compliant with your expectations.
FWIW
Loic
Copy link to clipboard
Copied
Hi Loic,
actually i have many files to change fonts in all PS on it so i have to create a script can do multiple find/change fonts in all paragraph styles on all opened documents with (locked/unlocked) frames
i hope you got my point
Suzan
Copy link to clipboard
Copied
use to unlocking all
app.menuActions.itemByID(11396).invoke();
Copy link to clipboard
Copied
Hi tbk1982,
well your line works well to unlock all in active document only, i always face same problem can't re code any script to be applied on all opened documents
please any hint or help
BR
Suzan
Copy link to clipboard
Copied
and btw what about my question for character styles, any hint for this code i posted?
Copy link to clipboard
Copied
It works try this
var docs = app.documents;
for (var d = docs.length-1; d >= 0; d--) {
var doc=docs
; var cstyles = doc.characterStyles;
for (var a = 0; a < cstyles.length; a++) {
if (cstyles.appliedFont=="Cambria" && cstyles.fontStyle =="Bold") {
cstyles.appliedFont = "Cambria"
cstyles.fontStyle = "Bold Italic"
}
}
}
Copy link to clipboard
Copied
to unlock text frames for all open documents.. use this
var docs = app.documents;
for (var d = docs.length-1; d >= 0; d--) {
var doc=docs
; var pgItems = doc.allPageItems;
for (var a = 0; a < pgItems.length; a++) {
if(pgItems instanceof TextFrame){
pgItems.locked = false;
}
}
}
Thanks,
K
Copy link to clipboard
Copied
Hi K,
sorry for bothering you again and again.
i got this error wid your code !!
Copy link to clipboard
Copied
May be your text frame grouped.. try this
var docs = app.documents;
for (var d = docs.length-1; d >= 0; d--) {
var doc=docs
var pgItems = doc.allPageItems;
for (var a = 0; a < pgItems.length; a++) {
if(pgItems instanceof TextFrame){
while (doc.groups.length > 0)
doc.groups.everyItem().ungroup();
pgItems.locked = false; }
}
}
Copy link to clipboard
Copied
again you saved my day
thanks a lot dear
BR,
Suzan
Copy link to clipboard
Copied
tpk1982 wrote:
It works try this
var docs = app.documents; for (var d = docs.length-1; d >= 0; d--) { var doc=docs; var cstyles = doc.characterStyles; for (var a = 0; a < cstyles.length; a++) { if (cstyles.appliedFont=="Cambria" && cstyles.fontStyle =="Bold") { cstyles.appliedFont = "Cambria" cstyles.fontStyle = "Bold Italic" } } }
works great, i see now the difference with my code was the line
var docs = app.documents; for (var d = docs.length-1; d >= 0; d--) { var doc=docs; var cstyles = doc.characterStyles; for (var a = 0; a < cstyles.length; a++) { if (cstyles.appliedFont=="Cambria" && cstyles.fontStyle =="Bold") { cstyles.appliedFont = "Cambria" cstyles.fontStyle = "Bold Italic" } } }
thanks a lot dear
now only last issue about locked frames