Skip navigation
Currently Being Moderated

Character Styles are lost???

May 3, 2012 2:15 AM

Hi all,

 

 

I have now experienced with all the character styles are lost when I apply paragraph style using "appliedParagraphStyle".

 

 

var myText = myTextFrame.parentStory.paragraphs.item(1);
myText.appliedParagraphStyle = myDocument.paragraphStyleGroups.item("Text").paragraphStyles.item("FC ");

 

 

any idea?

 

 

Thanks

Selva

 
Replies
  • Currently Being Moderated
    May 3, 2012 2:37 AM   in reply to Selva_TRM

    If you use the applyParagraphStyle method of a text object instead of

    changing its appliedParagraphStyle property, you get the option of

    choosing whether to clear local overrides. So try:

     

    myText.applyParagraphStyle(myParaStyle, false);

     

    HTH,

    Ariel

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 7:43 AM   in reply to Selva_TRM

    Hi Selva,

     

    The Ariel solution its working fine, please find the below snapshot & js code.

     

    Selva_TRM wrote:

     

    Sorry, its not working.

     

     

    Selva

     

    var myDoc = app.activeDocument;
    var myTextFrame = myDoc.textFrames[0];
    var myText = myTextFrame.parentStory.paragraphs.item(1);
    //var myParaStyle = myDoc.paragraphStyles.item("1");
    var myParaStyle = myDoc.paragraphStyleGroups.item("Text").paragraphStyles.item("FC");
    myText.applyParagraphStyle(myParaStyle, false);
    

     

     

    thx

    csm_phil

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 8:32 AM   in reply to Selva_TRM

    There is nothing left to be preserved, so that's why the 'preserve overrides' trick doesn't work for you:

     

    Selva_TRM wrote:

     

     

        myTextFrame.parentStory.insertionPoints.item(-1).contents = "\r"+myTextFrame1.contents;

     

    BAM! All your formatting is gone.

    See, for instance, this recent thread for more on this: replacing text that maintains styling issue

    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points