How to apply bold character style with grep

finding bold characters in a particular paragraph style
I want to apply a character style
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.string = String.Bold;
if (app.findGrepPreferences.appliedParagraphStyle == myPar) {
app.changeGrepPreferences.appliedCharacterStyle = myCar1;
app.activeDocument.changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;

Try this,
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.fontStyle = "Bold";
app.findGrepPreferences.appliedParagraphStyle = "myPar";
app.changeGrepPreferences.appliedCharacterStyle = "myCar1";
app.activeDocument.changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
Vandy

Similar Messages

  • How to apply a Character Style that's already been made in a template document?

    First of all I'd like to thank everyone that helps. I'm a complete beginner at scripting and appreciate all your help.
    I'm basically using GREP expressions to find patterns in a document and apply a Character Style which has already been made. This Character style was not made using script, but just in InDesign when making and setting up the template.
    var myDoc = app.activeDocument;
    //Clear the find/change grep preferences.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    //GREP Expression for finding all HEADERS
    app.findGrepPreferences.findWhat = ".+\n";
    //Applying formatting changes to put into All Caps, Bold and changing the font size to 12 pt.
    app.changeGrepPreferences.capitalization = Capitalization.allCaps;
    app.changeGrepPreferences.fontStyle = "Bold";
    app.changeGrepPreferences.pointSize = "12";
    myDoc.changeGrep();
    //Clear the find/change preferences after the search.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    This is how I currently have it. I will manually define the changes to the text. The problem is, each template uses a different set of fonts and not all of them use Bold e.g. Sabon can use CE Bold.
    I would like to learn how to apply a Character Style and have tried looking around but nothing seems to work.
    Any help would be much appreciated.
    Thanks.

    select the text where u went  and run below  script after change group as per ur template.
    var myDoc = app.activeDocument;
    var mySel = app.selection[0];
    //Clear the find/change grep preferences.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    //GREP Expression for finding all HEADERS
    app.findGrepPreferences.findWhat = "role";
    //Applying formatting changes to put into All Caps, Bold and changing the font size to 12 pt.
    //app.changeGrepPreferences.capitalization = Capitalization.allCaps;
    //~ app.changeGrepPreferences.fontStyle = "Bold";
    //~ app.changeGrepPreferences.pointSize = "12";
    app.changeGrepPreferences.appliedCharacterStyle=myDoc.characterStyleGroups.item("Style Group 1").characterStyleGroups.item("Style Group 2").characterStyles.item("Header")// Header is name of character name
    mySel.changeGrep();
    //Clear the find/change preferences after the search.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    If it's help then click yes
    Mi_D

  • How to apply inmath character style to fraction values

    Hi
    I try to apply inmath style to fraction values in indesign file.
    My code here:
    app.findGrepPreferences = NothingEnum.nothing;
                   app.changeGrepPreferences = NothingEnum.nothing;
                   app.findGrepPreferences.findWhat = myText;
                   app.changeGrepPreferences.appliedCharacterStyle = "Fraction Answers";
       app.changeGrep();             
    But it throws error "Invalid value for set property 'appliedCharacterStyle'
    Thanks
    Sangeetha

    Try this,
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.fontStyle = "Bold";
    app.findGrepPreferences.appliedParagraphStyle = "myPar";
    app.changeGrepPreferences.appliedCharacterStyle = "myCar1";
    app.activeDocument.changeGrep();
    app.findGrepPreferences = app.changeGrepPreferences = null;
    Vandy

  • How to apply a user style with the Stylish extension for Web Developer Tools?

    I have firefox 27 and the fonts of Web Developer Tools (Inspector, Debugger..) are very small.
    The fonts of Stylish editor are very small also.
    Here https://support.mozilla.org/en-US/questions/943857 I found a similar question.
    GingerBread Man said :
    "If you need to modify anything else, you can use the DOM Inspector extension to examine user interface elements ("chrome"). "
    My problem is that I can't find the names of elements e.g "chrome://browser/content/devtools/markup-view.xhtml"

    @the-edmeister
    Thanks for your reply.
    The rule below affects only Inspector
    @namespace url(http://www.w3.org/1999/xhtml);
    @-moz-document url("chrome://browser/content/devtools/markup-view.'''xhtml'''") {
    .devtools-monospace {
    font-size: 120% !important;
    I change the rule as you suggest.
    @-moz-document url("chrome://browser/skin/devtools/markup-view.css") { ......}
    It doesn't work.

  • Break link to Character Style with JS (CS4ME)

    Hi,
    I'm wondering how to break a link to a character style in JS. By break
    link I mean removing the character style but preserving the formatting.
    Given a selected textStyleRange, say, in the UI there are two ways of
    doing this. One is to click "Break link to Style" in the flyout meny of
    the character style palette.
    The other is to right-click and select "Apply character style."
    It's a little unintuitive, because CLICKING on removes overrides,
    but right-clicking and selecting the menu option doesn't.
    So when I saw that, I said to myself aha! Probably:
    myText.appliedCharacterStyle = myCharStyle
    is equivalent to clicking on , while
    myText.applyCharacterStyle(myCharStyle)
    is equivalent to right-clicking on and choosing "Apply character
    style."
    But it isn't.
    They both apply None and remove all formatting.
    So, anyone know how to break a link to character style without removing
    formatting in JS?
    Thanks,
    Ariel

    Thanks Peter. That's interesting. After Shabbos I'll have to try figure
    out how to apply a character style without removing overrides as well.
    It may be a two-step procedure.
    Thanks,
    Ariel

  • How do I apply a character style to a sentence that has an '&' in it?

    Hi all,
    I'm trying to apply the Character style 'See Figure' to any mention of of the phrase (See Figure x) which  I've figured out is: \(See Figure \d+\)
    The problem I'm facing is that sometimes I will need to list multiple figure references. It will need to read (See Figure x&y) and in rare cases (See Figure x,y&z)
    NOTE: There are no spaces in the above listed numbers.
    Thank you  for your help.

    That works perfectly, thank you very much.
    Can you break it down for me in English if you have a moment please? I think I'm reading it wrong.
    Digit followed by an Ampersand (I'm confused by the square bracket and plus...)

  • How to effectively use Character Styles

    Hello, I am fairly new to InDesign, but have an extensive background with FrameMaker. I am having trouble figuring out how to best use character styles in ID, because of the difference between it and FM.
    Lets say I have two different body text styles, which use different fonts or different sizes, each of which is saved as a paragraph style.
    In Framemaker, when you go into the Character Style editor, for each value you can select the value "As Is". So if I want to make a Bold character style, I leave the font and size attributes set to "As Is" and I change only the weight attribute to Bold.
    Now, I can select either Body Text 1 or Body Text 2 for the paragraph style and if I want to bold a word, I just highlight that word and select the Bold character style. The text is bolded but everything else that is unique to that paragraph style remains. If I ever need to unbold the word, I can just select it and then select No Style from the Character Style catalog
    But in ID, it looks like you have to define the value for each attribute in the Character Style editor. So I would need to create two separate bold styles, one for each paragraph style, because if I define the font and size, it will switch those  values as well as the weight. And if I need to create a separate Bold Character style for each paragraph style in which the default font is not bolded, what is the advantage of using character styles? Why not simply highlight the text and select the bold value from the Character palette, which then modifies the paragraph style just for those words that you bolded?

    Thanks,
    I was looking at some existing documents, which I think were created by folks who didn't know what they were doing (I am new to this job and all of the previous folks doing what I do are gone - and they clearly did not understand how to properly use styles). All of the fields had values in them, and when I didn't see an "As Is" value, it never occurred to me that I could just highlight the value and delete it to get rid of it.
    When you use a bunch of different Adobe products, even though they  have  fairly similar user interfaces, it is those differences that really get you.....
    Thanks, again

  • Numbered bullet character style with underline not showing

    Hi,
    I have a paragraph style for numbered bullets where I've used a character style for the numbered bullet.
    The character style has an underline applied so the effect looks like white text on a blue box, the blue box being created by the underline.
    The 'Paper' coloured number is showing, I can see it by placing a coloured box behind the text box to test.
    But the blue underline is not showing. When I apply the character style on other text it works fine.
    Could this be a bug?
    InDesign CC, Mac OS X 10.8.4

    Thanks for responding.
    "Paper" is the colour I am using for the character colour and then using another named colour for the underline.
    But it is happening the same as you suggest in your screengrab.
    In my screengrab below I have put in a black box to show that there is no underline appearing!
    And my paragraph style with that character style applied:
    So how do we submit this as a bug? And why hasn't it been fixed before now?!!!
    thanks.

  • How To apply bold property to the table header

    Hi All,
    Please advice me that how to apply bold property and backgroud color to the table column header.?
    Any help is greatly appreciated.
    Thanks in advance.
    Sathya Rani M

    You can loop through the rows and apply the "fillColor" property for rows. Loop length is the "headerRowCount" of the table.
    In the same loop you could also loop (a loop within a loop) through all cells of a row and set its "texts" obejct, which is an array, to the text style you wish. Or you could apply a paragraph style or a character style, that is pre-defined.
    Uwe

  • How to apply multiple paragraph styles to one sentence?

    I'm using paragraph styles but is not helpful because I'm trying to apply 2 different styles within the same sentence which is not working.
    To make it work I select the sentence, apply the style, for instance "xfont-regular" then I select the word within the sentence that I want it to have a different style and I choose from the font list maybe italic so that it looks "something like this"
    Obviously by doing this, I'm loosing all the benefits of using p styles and of course it's so time consuming. Is there any way to break the sentence, keeping it in the same line, so that I can apply different styles to it? and still keep the benefits of just going to the styles and make the changes to the whole document that have that style applied.
    Thank you

    pchinique wrote:
    I'm using paragraph styles but is not helpful because I'm trying to apply 2 different styles within the same sentence which is not working.
    To make it work I select the sentence, apply the style, for instance "xfont-regular" then I select the word within the sentence that I want it to have a different style and I choose from the font list maybe italic so that it looks "something like this"
    Obviously by doing this, I'm loosing all the benefits of using p styles and of course it's so time consuming. Is there any way to break the sentence, keeping it in the same line, so that I can apply different styles to it? and still keep the benefits of just going to the styles and make the changes to the whole document that have that style applied.
    Thank you
    As Diane King mentioned, nested character styles may work for your need. Her example was an initial dropped capital (multi-line first one or several letters of a paragraph.) Dropped caps are a specific type of nested style - always the first one or more characters in a paragraph, two or more lines high.
    To use the general kind of nested style, you need to be able to identify the word or words within the paragraph that gets the nested character style. For example, the third word, or the first two words after the first semi-colon. If there is no pattern of word(s) that can be identified by position or sequence, it's possible that a GREP style can be used to find a common pattern of characters and apply a character style to it, for example a telephone number, date, or currency amount that's identified by a dollar sign, pound, or yuan.
    Search InDesign Help and Google for "InDesign nested style," "InDesign grep style," and similar terms (without quotes) for details. There have been many discussions of GREP on this forum.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • How can I apply a new style with a snippet and make DW remove artifacts of the old style?

    Hello,
    I am using Dreamweaver CS5 on Windows XP SP3. My problem seems simple but the resolution remains elusive.
    Let's say I am editing pasted-in text from MS Word that DW has auto-formatted. I highlight some text and use a snippet to enclose the text in h2.
    Instead of deleting the former style and replacing it with h2, DW applies the h2, but copies the old style, enclosing nothing, and bumps it to the next line. If the old style included a paragraph tag, that throws in extra white space. For nothing at all.
    Now, this seems like a minor thing, but it's not so minor when you are trying to quickly prepare a large document with various header styles. Having to make dozens of edits that I think should be completely unnecessary becomes a real burden.
    Is there a way to enclose a bit of text in a new style with a snippet without having the old style stick around?
    Thanks for any and all replies!
    Michael Salmons

    Maybe auto-format is not the correct terminology, but DW does interpret MS Word formatting in some way,and in a way I cannot control (well, I can to a limited degree). The term that popped into my head describing this process was automatic formatting.
    I don't really want to paste in as text, then I have to touch everything. I mean, I do frequently end up touching everything in a document anyway, but if any decisions can be "automated," I like to at least give it a try.
    DW makes mostly good guesses* about Word formatting (*or whatever mechanism translates word formatting to html in DW). Even if it is just a little wrong, it saves me a lot of time. <p><strong> can be converted to <h2> faster than text that only has a CRLF to distinguish it from surrounding text.
    I'm not mixing any styles. I control the style absolutely. I would just like to know how to use snippets in a way that truly replaces the Word-suggested tags rather than preserving them for no good reason. Perhaps there is no way to do that, or I so fundamentally misunderstand snippets I am fooling myself.

  • Bold character style does not inherit the paragraph emphasis (Italic)

    Hi,
    I am using TCS2 (RH 8, FM 9).
    I have a character style in FrameMaker that makes GUI terms bold.  My text for Notes, Tips and so in is italic and when I apply my GUI character style in FM, the text becomes both bold and italic.  In RoboHelp, my text with the GUI character style is only Bold.
    Is there a way to change this in the CSS or elsewhere?
    Here is what I want to see:
    If you select Widget, make sure you also select OtherWidget.
    Here is what I get:
    If you select Widget, make sure you also select OtherWidget.
    Thanks,
    Lauren

    Hi, Just trying to raise the profile of my question.  anyone have any thougths, even if it is you can't do it?
    Lauren

  • How to apply one character tag to paragraphs having different tags?

    Hi,
    I'm using FrameMaker 8 on Windows.
    I'm trying to create a character tag that marks certain paragraphs so they're easier to find later. The only thing I want to change is the color. I want all the other attributes, regardless of the paragraph tag, to remain as they are.
    Here's what I've done:
    First, I highlighted the text to be changed. The text in this paragraph had font size 10 and regular weight.
    I selected New Format from the Commands menu, named it "Rewrite" and added it to the catalog.
    In the Character Designer, I set the size and weight to "As is", selected the new color, and clicked "Apply".
    So far, so good - the text is the same as before in every way except the color.
    Later, I wanted to mark some other text with this character tag. This text was in a paragraph that had a font size of 14 and bold weight. I highlighted the text and applied the "Rewrite" character tag.  I was expecting to see the highlighted text change color, but remain the same otherwise.
    However, instead of changing only the color, the character tag changed the font size to 10 and the weight to regular. It seems that, when I created the character tag and selected "As is" for the font size, this was interpreted as meaning, "Use the font size that is currently defined in this paragraph tag as the font size for this character tag." Sure enough, when I looked at the character Designer, the size was set to 10 and the weight to regular, instead of "As is" for both.
    Am I misunderstanding how to use "As is?" How can I get it to work the way I want it to?
    Thank you!
    Joyce Wermont

    CAVEAT: I'm working from memory, and this may work differently in later releases.
    To create a completely As Is character format, deselect all text before using the character designer. The "SeSet the values for the properties you want in the format. Click Create, or Update All.
    To make it work without problems, select all the text in a paragraph, but don't select the paragraph mark, then apply the character format to the selection. Applying a character format to the paragraph mark confused earlier FM releases - not sure if it's still true in later releases.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices
    jwermont wrote:
    Hi,
    I'm using FrameMaker 8 on Windows.
    I'm trying to create a character tag that marks certain paragraphs so they're easier to find later. The only thing I want to change is the color. I want all the other attributes, regardless of the paragraph tag, to remain as they are.
    Here's what I've done:
    First, I highlighted the text to be changed. The text in this paragraph had font size 10 and regular weight.
    I selected New Format from the Commands menu, named it "Rewrite" and added it to the catalog.
    In the Character Designer, I set the size and weight to "As is", selected the new color, and clicked "Apply".
    So far, so good - the text is the same as before in every way except the color.
    Later, I wanted to mark some other text with this character tag. This text was in a paragraph that had a font size of 14 and bold weight. I highlighted the text and applied the "Rewrite" character tag.  I was expecting to see the highlighted text change color, but remain the same otherwise.
    However, instead of changing only the color, the character tag changed the font size to 10 and the weight to regular. It seems that, when I created the character tag and selected "As is" for the font size, this was interpreted as meaning, "Use the font size that is currently defined in this paragraph tag as the font size for this character tag." Sure enough, when I looked at the character Designer, the size was set to 10 and the weight to regular, instead of "As is" for both.
    Am I misunderstanding how to use "As is?" How can I get it to work the way I want it to?
    Thank you!
    Joyce Wermont

  • How do I export character styles as XML?

    I have a load of InDesign CS4 files. They contain paragraph styles, but do not appear to have any explicit character styles, though do contain content that is rendered as italic, bold, superscript content etc.
    I have associated the paragraph styles with some imported tags and exported them successfully as XML, BUT I can't find a way of grabbing hold of the character styles in the same way.
    Very grateful for some guidance on this.
    Thank you
    Brad

    It sounds like your problem is that the character styling has been applied ad hoc - i.e., without character styles.
    I would suggest creating all the character styles you need/want first. Then, you can use the Find/Change feature to find all text with a certain styling, and apply the appropriate character style to it. You'll need to think through the order in which you do the various Find/Change operations. For example, you will want to find all cases of Bold + Italic and replace with a Bold + Italic character style before you carry out the process for text that is simply either Bold or Italic.
    Once you have the Character Styles applied, you can map them to XML tags just as you did with the Paragraph Styles.

  • Applying [None] character style

    I have a script that finds text with a certain character style, cuts that text from the main story and anchors it in a frame that sits in the margin.
    Everything works fine except that I'd like to have the option of removing the character style. However, when I apply the [None] character style InD shows [None] in the character style lists but the formatting for the character style that was just removed remains on the text.
    Is there a way to have it work as if the [None] was manually selected from the character style list? i.e.: where the character style formatting is removed as well?
    Thanks,
    Ken

    Hello!
    I'm trying to start understanding this javascript thing... Does anyone know how I can modify this so it will also have the option of removing all the character styles in all the text frames, or all the stories in the document? I have several documents with 10 stories each that will need to have the character styles removed before we continue formatting.
    I took a swing at it myself, but haven't been able to get it to work. I really don't know much about scripting! Here's what I tried:
    if (app.documents.length == 0) ErrorExit("Please open a document and try again.");   
    var gScriptName = "Apply character style None keeping overrides"; 
    var gScriptVersion = "1.0"; 
    var doc = app.activeDocument; 
    var sel = doc.selection[0]; 
    var all = app.documents[0].stories.everyItem()
    if (doc.selection.length != 1) ErrorExit("One text frame or some text should be selected, or the cursor should be inserted into the text."); 
    if (sel.constructor.name == "TextFrame") { // a text frame is selected 
         ApplyNone(sel.texts[0]); 
    else if (sel.constructor.name == "Character" || // some text is selected  
         sel.constructor.name == "Word" || 
         sel.constructor.name == "TextStyleRange" || 
         sel.constructor.name == "Line" || 
         sel.constructor.name == "Paragraph" || 
         sel.constructor.name == "TextColumn" || 
         sel.constructor.name == "Text") 
              ApplyNone(sel); 
    else { 
         ApplyNone(all); 
    //===================================== FUNCTIONS  ====================================== 
    function ApplyNone(sel) { 
         var noneStyle = doc.characterStyles.item("[None]"); 
         var basedOnNone = app.activeDocument.characterStyles.add({name:"None", basedOn:noneStyle}); 
         sel.applyCharacterStyle(basedOnNone); 
         basedOnNone.remove(noneStyle); 
    function ErrorExit(error, icon) { 
         alert(error, gScriptName + " - " + gScriptVersion, icon); 
         exit(); 
    I also tried this, but to no avail.
    ar gScriptName = "Apply character style None keeping overrides"; 
    var gScriptVersion = "1.0"; 
    var doc = app.activeDocument; 
    var sel = doc.selection[0]; 
    var all = app.documents[0].stories.everyItem()
    ApplyNone(all); 
    //===================================== FUNCTIONS  ====================================== 
    function ApplyNone(sel) { 
         var noneStyle = doc.characterStyles.item("[None]"); 
         var basedOnNone = app.activeDocument.characterStyles.add({name:"None", basedOn:noneStyle}); 
         all.applyCharacterStyle(basedOnNone); 
         basedOnNone.remove(noneStyle); 
    function ErrorExit(error, icon) { 
         alert(error, gScriptName + " - " + gScriptVersion, icon); 
         exit(); 
    Any thoughts? I'm thinking that app.documents[0].stories.everyItem() probably isn't right...
    Thanks for your help!

Maybe you are looking for

  • IBook doesn't power on

    Hello I have an iBook G3 500 mhx ppc g3 256 mb or ram 15 Gb Hard drive Dual booting Mac OS X 10.1 and 10.3. I was going to upgrade the os but when I turned it on I heared the Hard drive turn on and then It turned off and nothing on the screen. I trie

  • How to create watch points in ECC 6.0

    Hi Experts, How to create watch points in ECC 6.0 Thanks.

  • Average Daily Balancing

    I have a requirement for a business unit to run on average daily balancing in GL. I have several other business units which do not require this. They can share chart of accounts and are all in the one currency. What is the recommendation in moving fo

  • Novell Access Manager J2EE Agent Installation

    First post and first time attempting to install NETIQ unto my desktop. I'm a little confused as to the section of "Novell Access Manager J2EE Agent Installation" and what to enter for my Admin Console IP Address, username, password, & Application Ser

  • 2LIS_11_VAHDR right-click not showing Transfer Rules

    Dear gurus, I have 2LIS_11_VAHDR under my SD Application Components at DataSources tab. I replicated the datasource with ECC and activated it. Now I want to install the rest of the dataflow - transfer rules, infosource, update rules, sd_c03, and the