Copy link to clipboard
Copied
Hi All,
Can someone help modify my script so it could also edit styles in Style Group. I tried several time by creating a nested loop under another the variable for paragraphStyleGroups but I can't get it to work.
myDoc = app.activeDocument;
myStyles = myDoc.paragraphStyles;
myCStyles = myDoc.characterStyles;
for (i = 1; i < myStyles.length; i++)
{
myStyle = myStyles;
myStyle.appliedLanguage = "Spanish";
}
for (i = 1; i < myCStyles.length; i++)
{
myCStyle = myCStyles;
myCStyle.appliedLanguage = "Spanish";
}
Your help will be appreciated.
Thanks,
Kel
Use allParagraphStyles and allCharacterStyles.
myStyles = myDoc.allParagraphStyles;
myCStyles = myDoc.allCharacterStyles;
Shonky
Copy link to clipboard
Copied
Just change myDoc.paragraphStyles to myDoc.allParagraphStyles
and myDoc.characterStyles to myDoc.allCharacterStyles
Harbs
Copy link to clipboard
Copied
oops, i had opened thread and reply late.
Copy link to clipboard
Copied
It work. Thank you so much.
Copy link to clipboard
Copied
Hi Harbs
I need to change the Name of the Styles using a Script.
If the Style is not in a Group the below script works but if the style is in a Group it is not getting renamed.
var myDoc=app.activeDocument;
var myStyle=myDoc.paragraphStyles.itemByName(oldStyle);
alert(oldStyle);
alert(newStyle);
myStyle.name=newStyle;
Please HELP!!!
Thanks
Saai
Copy link to clipboard
Copied
Use allParagraphStyles and allCharacterStyles.
myStyles = myDoc.allParagraphStyles;
myCStyles = myDoc.allCharacterStyles;
Shonky
Copy link to clipboard
Copied
Hi Shonky
I need to change the Name of the Styles using a Script.
If the Style is not in a Group the below script works but if the style is in a Group it is not getting renamed.
var myDoc=app.activeDocument;
var myStyle=myDoc.paragraphStyles.itemByName(oldStyle);
alert(oldStyle);
alert(newStyle);
myStyle.name=newStyle;
Please HELP!!!
Thanks
Saai
Copy link to clipboard
Copied
If you want change style name within group then you need to go through all style compare with your old style and rename with new one.
Check below code:
var myDoc=app.activeDocument;
var myallParaSyles = myDoc.allParagraphStyles;
for(a=2; a<myallParaSyles.length; a++)
{
if (myallParaSyles.name == oldStyle);
{
myallParaSyles.name = newStyle;
}
}
Shonky
Copy link to clipboard
Copied
Hi Saai,
Footnote creation:
var doc, root, childs, max = 0;
if(app.documents.length==0)
{}else
{
doc = app.activeDocument;
root = doc.xmlElements[0];
childs = root.evaluateXPathExpression("//footnote");
max = childs.length;
if(max==0){}else{
alert(max);
for(var i = 0; i< max; i++){
childs.xmlContent.select();
var fnText = app.activeDocument.selection[0];
var fNote = app.activeDocument.selection[0].footnotes.add(LocationOptions.BEFORE, fnText.insertionPoints[0]);
fNote.texts[0].insertionPoints[-1].contents = fnText.contents;
fnText.remove();
}
}
}
Copy link to clipboard
Copied
Dear Bala
Please help me with the below.
<section id="ch12lev1bm" role="bm">
<title id="ch12lev1bm.title"/>
<para aid:pstyle="CHAP_BM_FIRST">The foreign-exchange market is the market where domestic money can be exchanged for foreign, and hence it is where the prices of many currencies are set. The price of foreign money is known as the <link linkend="ch12mn01" preference="1" type="forward">
<keyterm id="ch12term01" role="strong" linkend="ch12gloss01_01" preference="0" aid:cstyle="KT">exchange rate</keyterm>
<?boxCitation type=MN3?>
</link>
<emphasis role="strong" aid:cstyle="BOLD">,</emphasis> denoted throughout the text by the letter E. Unlike the New York Stock Exchange, the foreign-exchange market is not located in any one location. Rather, it is best thought of as a worldwide network of commercial banks linked together by a sophisticated communications technology. Without doubt, it is the world’s largest market; current estimates place the volume of average <emphasis aid:cstyle="ITAL">daily</emphasis> worldwide trade at $4 trillion.<footnoteref preference="1" label="1" linkend="ch12fn01">
<insert aid:cstyle="SUP">1</insert>
</footnoteref> It is also one of the most efficient. It is characterized by low barriers to entry, a homogeneous commodity (money), many buyers and sellers none of whom has significant market power, and almost perfect information. Thus, it possesses all of the characteristics of a perfectly competitive market. And, because of its overall size and international dimensions, it is totally unregulated by any national or international government.</para>
<footnote id="ch12fn01" label="1">
<insert aid:cstyle="SUP">1</insert>
<para aid:pstyle="FN">
<emphasis aid:cstyle="ITAL">Triennial Central Bank Survey: Report on global foreign exchange market activity in 2010</emphasis> (Basel: Bank for International Settlements, December 2010). Available at: <ulink url="http://www.bis.org/publ/rpfxf10t.pdfhttp://www.bis.org/publ/rpfxf10t.pdf">http://www.bis.org/publ/rp...>. See the summary of main findings for more detail.</para>
</footnote>
<marginalnote id="ch12mn01" float="1" type="mn3">
<glossary id="ch12gloss01">
<glossentry id="ch12gloss01_01">
<glossterm aid:pstyle="MN3_GLOS_GT">Exchange rate</glossterm>
<insert> </insert>
<glossdef>
<para aid:pstyle="MN3_GLOS_DEF">The price of one country’s money in terms of another.</para>
</glossdef>
</glossentry>
</glossary>
</marginalnote>
</section>
Use this for testing,
1. the <insert aid:cstyle="SUP">1</insert> should be be moved
Thanks
Saai Murugan
Copy link to clipboard
Copied
var doc, root, childs, max = 0;
if(app.documents.length==0)
{}else
{
doc = app.activeDocument;
root = doc.xmlElements[0];
childs = root.evaluateXPathExpression("//footnote");
max = childs.length;
if(max==0){}else{
alert(max);
for(var i = 0; i< max; i++){
for(var i1=0; i1 < childs.xmlElements.length; i1++) {
switch (childs.xmlElements[i1].markupTag.name){
case "insert":
var myLabel = childs.xmlElements[i1];
break;
case "para":
var myText = childs.xmlElements[i1];
break;
default:
break;
}
}
childs.xmlContent.select();
var fnText = app.activeDocument.selection[0];
var fNote = app.activeDocument.selection[0].footnotes.add(LocationOptions.BEFORE, fnText.insertionPoints[0]);
app.select(myText.xmlContent);
app.copy();
app.select(fNote.texts[0].insertionPoints[-1]);
app.paste();
//myText.remove();/*If need to remove tag also*/
//myLabel.remove();/*If need to remove tag also*/
myText.xmlContent.remove();
myLabel.xmlContent.remove();
}
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now