Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Replace language of styles in Style Group

Guest
Apr 12, 2010 Apr 12, 2010

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

TOPICS
Scripting
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Apr 12, 2010 Apr 12, 2010

Use allParagraphStyles and allCharacterStyles.

myStyles = myDoc.allParagraphStyles;

myCStyles = myDoc.allCharacterStyles;

Shonky

Translate
LEGEND ,
Apr 12, 2010 Apr 12, 2010

Just change myDoc.paragraphStyles to myDoc.allParagraphStyles

and myDoc.characterStyles to myDoc.allCharacterStyles

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 12, 2010 Apr 12, 2010

oops, i had opened thread and reply late.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 12, 2010 Apr 12, 2010

It work. Thank you so much.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 24, 2010 May 24, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 12, 2010 Apr 12, 2010

Use allParagraphStyles and allCharacterStyles.

myStyles = myDoc.allParagraphStyles;

myCStyles = myDoc.allCharacterStyles;

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 24, 2010 May 24, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 24, 2010 May 24, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 28, 2012 Aug 28, 2012

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();

            } 

        }

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 28, 2012 Aug 28, 2012

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>&#13;</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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 29, 2012 Aug 29, 2012
LATEST

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();

            } 

        }

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines