Apply Clear Overrides after creating such character styles...

Hi everyone,
After importing the Word document into InDesign CS3 in some of the paragraphs there is some style overrides. The InDesign styles formatting are not intented with the paragraphs properly. Eventhough the word styles are mapped with InDesign styles exactly. If i select all the paragrahs and click the option "Clear Overrides" from the paragraph styles palette, all the InDesign styles formatting are applied properly but the character style formatting get removed. So i have planned to create script to character style for each font style and each formatting of the characters. After doing this i can clear the overrides of paragraph styles without hassle. I have created the script to create character styles for character formatting and its working fine but when i tried to run this script for 2nd time in the same document it showing some error in it. Please find my script below and it is too big,
//To find Font styles and character formatting and replacing it with character styles
//Script for CS3
#target InDesign
var myDoc = app.activeDocument;
if (myDoc.characterStyles.item("Itl") == null){
var Itl = myDoc.characterStyles.add({name: "Itl", fontStyle: "Italic"});}
if (myDoc.characterStyles.item("bl") == null){
var bl = myDoc.characterStyles.add({name: "bl", fontStyle: "Bold"});}
if (myDoc.characterStyles.item("bItl") == null){
var bItl = myDoc.characterStyles.add({name: "bItl", fontStyle: "BoldItalic"});}
if (myDoc.characterStyles.item("bItal") == null){
var bItal = myDoc.characterStyles.add({name: "bItal", fontStyle: "Bold Italic"});}
if (myDoc.characterStyles.item("sb") == null){
var sb = myDoc.characterStyles.add({name: "sb", fontStyle: "Semibold"});}
if (myDoc.characterStyles.item("sbItal") == null){
var sbItal = myDoc.characterStyles.add({name: "sbItal", fontStyle: "Semibold Italic"});}
if (myDoc.characterStyles.item("blk") == null){
var blk = myDoc.characterStyles.add({name: "blk", fontStyle: "Black"});}
if (myDoc.characterStyles.item("obl") == null){
var obl = myDoc.characterStyles.add({name: "obl", fontStyle: "Oblique"});}
if (myDoc.characterStyles.item("li") == null){
var li = myDoc.characterStyles.add({name: "li", fontStyle: "Light"});}
if (myDoc.characterStyles.item("liItal") == null){
var liItal = myDoc.characterStyles.add({name: "liItal", fontStyle: "Light Italic"});}
if (myDoc.characterStyles.item("sup") == null){
var sup = myDoc.characterStyles.add({name: "sup", position: Position.superscript});}
if (myDoc.characterStyles.item("sub") == null){
var sub = myDoc.characterStyles.add({name: "sub", position: Position.subscript});}
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences = null;
app.changeTextPreferences = null;
app.findTextPreferences.fontStyle = "Italic";
app.changeTextPreferences.appliedCharacterStyle = Itl;
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Bold";
app.changeTextPreferences.appliedCharacterStyle = bl;
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "BoldItalic";
app.changeTextPreferences.appliedCharacterStyle = bItl;
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Bold Italic";
app.changeTextPreferences.appliedCharacterStyle = bItal;
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Semibold";
app.changeTextPreferences.appliedCharacterStyle = sb;
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Semibold Italic";
app.changeTextPreferences.appliedCharacterStyle = sbItal;
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Black";
app.changeTextPreferences.appliedCharacterStyle = blk;
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Oblique";
app.changeTextPreferences.appliedCharacterStyle = obl;
app.documents.item(0).changeText();
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Light";
app.changeTextPreferences.appliedCharacterStyle = li;
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Light Italic";
app.changeTextPreferences.appliedCharacterStyle = liItal;
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences.position = Position.superscript;
app.changeTextPreferences.appliedCharacterStyle = sup;
app.documents.item(0).changeText();
app.findTextPreferences.position = Position.subscript;
app.changeTextPreferences.appliedCharacterStyle = sub;
app.documents.item(0).changeText();
function setupFindText(find, change, foots, hidLayers, lockedLayers, lockedStories, masters, caseSensitive) {
  app.findTextPreferences = null;
  app.changeTextPreferences = null;
  try { app.findTextPreferences.findWhat = find } catch(e) {};
  try {app.changeTextPreferences.changeTo = change } catch(e) {};
  app.findChangeTextOptions.properties = {
    includeFootnotes:(foots == null ? false : foots),
    includeHiddenLayers:(hidLayers == null ? false : hidLayers),
    includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
    includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
    includeMasterPages:(masters == null ? false : masters),
    includeCaseSensitive:(caseSensitive == null ? false : caseSensitive)
} // end setupFindText
alert ("DONE");
please suggest how to simply this script and make it run faster can anyone suggest me. Also suggest me to how can add this "Clear Override" syntax with this script. I want to make this script very effective. Thanks in advance to all.
Regards
Thiyagu

The reason for that error is easy.
if (myDoc.characterStyles.item("Itl") == null){
var Itl = myDoc.characterStyles.add({name: "Itl", fontStyle: "Italic"});}
means "if the style does not exist, create it and assign it to the variable". What happens when it does exist? (I'll let you think of an answer here.)
Why don't overrides work? Well, let me ask you, does it work when you do the same directly in the program? No: to clear overrides, replace a style with itself. Does that mean you should run the script twice? Well, no, a brief search through the CS3 JS help reveals this tantalizing function (for any text type element):
void clearOverrides ([overridesToClear:OverrideType=ALL])
Clears the specified types of override.
Parameter
Type
Description
overridesToClear
OverrideType:
OverrideType.ALL
OverrideType.CHARACTER_ONLY
OverrideType.PARAGRAPH_ONLY
The types of override to clear. (Optional) (default: ALL)
-- and I remember someone posting this rather nifty one-liner
myStory.paragraphs.everyItem().clearOverrides();
The script appears a bit Frankensteinian to me. That function setupFindText is never used; you use two different ways of clearing the find and change preferences ('null' and 'nothing' -- I believe there were some strong points against using 'null', but, anyway, you only need to set them to nothing once).
Notice it doesn't take heed of combinations of a type style and superior/inferior -- the latter will overwrite the former.
The usual way of speeding up a script is by putting repeated elements into an array, but I doubt this will help much here. On the other hand, it's just a handful of replaces, and it should be very fast already. Even if it takes as much as 30 seconds, it's still worth that time.

Similar Messages

  • Clearing overrides in Cell and Table Styles causes crash

    I can not "Apply [...], Clear Overrides" in a Cell, Table or Paragraph style without InDesign CC crashing. I have removed all Object styles from the tables that I am working with. I tried exporting to .idml and starting a new file and have the same issue.

    @Chris – Is InDesign CC patched to the latest version?
    Are you interested to test a script by Marc Autret posted at the inDesign Scripting Forum?
    See the following thread and posts:
    creativejoan0425
    How to break link to cell/table style in a selection
    Dec 14, 2013 3:51 PM
    https://forums.adobe.com/message/5929954#5929954
    See Marc Autret's script for cleaning different levels:
    https://forums.adobe.com/message/5931169#5931169
    Change the last line of his code to your will. Basically you have 4 options. Chose *one* of those:
    Option 1 LEVEL 0:
    breakLinkToCellStyleSelection(0); // LEVEL 0  => only clear overrides relative to *defined* style attributes
    Option 2 LEVEL 1:
    breakLinkToCellStyleSelection(1); // LEVEL 1  => clear all overrides (through root style)
    Option 3 LEVEL 2:
    breakLinkToCellStyleSelection(2); // LEVEL 2  => clear all overrides and apply [None]
    Option 4 LEVEL 3:
    breakLinkToCellStyleSelection(3); // LEVEL 3  => apply [None] *in depth* (i.e. release all attributes)
    Select your cells or your table and run the whole script.
    Does it crash InDesign CC as well?
    Uwe

  • Clear form after CREATING record

    Right now when I fill out a form then click the CREATE button, the record shows up in the report but it also remains in the form in "edit"mode.
    What I want is after I click the CREATE button, the form clears and the CREATE button remains so I can add another record.

    I don't want to clear it for the whole page because I have 2 regions on this page. One region has a report, the other region is the form. So, when I create the record in the form I want the report to populate, but I want just the form region to clear cache. So, how do I clear the cache for just a region, not a page.

  • How to create new character styles in Numbers 3.0

    In Numbers 3.0, it is possible to update existing characters styles, but I cannot find how to create a new character style, the + sign in the popup is always inactive when I edit text in a cell. The paragraph style popup has an active +, but it doesn't work for character style.
    Is there any way to create a new character style?

    Guillame,
    You're right about not being able to add styles, and I have not figured out how to modify a predefined character style, other than to Rename or Delete a predefined style. I have added this to my list of things lost.
    Jerry

  • Make paragraph style not override character style?

    Hi.
    Is there any way to make a paragraph style NOT override a character style?
    For example, I write a lot of scientific reports in Pages and then I use subscript and superscript often and so I have made a character style for that. But if I want to perhaps change the spacing between paragraphs in my body style. I select a paragraph, change the settings that I want and then I right click on the paragraph style and choose "redefine style from selection". Then I select all of that style and choose "revert to defined style" to get the updated paragraph spacing. But what this does is that it overrides all of the character styles so that everything in sub/superscript, bold, italic etc get back to the style. This is really bugging me out.
    For the character styles you can select what attributes you want them to affect, is there any way to do this with paragraph styles as well? Or maybe some of you have got a good way to make it work.
    Thanks in advance.

    When you redefine the paragraph style, all paragraphs using that style will display the new style properties, unless you've overriden them. Presumably this is why you choose "revert to defined style", so that other paragraphs that you've stylistically modified take on the proper paragraph style properties. If not, why revert at all?
    Instead of using revert, why not re-apply the paragraph style (just click on the selected style in the drawer, or pick the selected item from the pop-up menu). It will discard your unwanted paragraph style overrides, and preserve the character styles.

  • How to specify character style to anchored objects markers depending on the objects formats?

    I have a long document contains much of anchored text frames with custom positions and want to delete them by aplying character styles to their markers.

    Create a new character style to apply it. And change the character style name in this code to yours, then execute it.
    main ();
    function main (){
        app.findGrepPreferences = NothingEnum.NOTHING;
        app.findGrepPreferences.findWhat = "~a";
        var objectsArray = app.activeDocument.findGrep();
        for (var c = 0; c < objectsArray.length; c++) {
            if (objectsArray[c].textFrames.length > 0) //The anchored object is a text frame
                var targetTextFrame = objectsArray[c].textFrames.item(0);
                var textFramePosition = targetTextFrame.anchoredObjectSettings.anchoredPosition;
                if (textFramePosition == AnchorPosition.ANCHORED) // the object have custom position
                    //Create a new charater style and change the character style name to yours. 
                    objectsArray[c].appliedCharacterStyle = app.activeDocument.characterStyles.itemByName("Delete");
    Then make a GREP search for this character style, and if you want delete them all by Change All button.

  • Automate character styles?

    Tuesday morning, I have to sit down and pop hundred and fifty summer events into a flyer. Choice A is easy - I can print them and type them. In the shower, though, I began thinking about Choice B, and I don't know whether InDesign can do what I want.
    I have control over the database where they're hosted, and it's pretty easy for me to pop them out in the format
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    Date - Time  [carriage return]
    Event name
    ~~~~~~~~~~~~~
    Date - Time  [carriage return]
    Event name
    ~~~~~~~~~~~~~
    Date - Time  [carriage return]
    Event name
    ~~~~~~~~~~~~~
    which is all the information I need on this document. On the finished product, though, I want Date and Time to have character styles applied (for color and weight). It's not that hard for me to assign hot keys to Character styles and do this by hand - just twenty minutes of tedium.
    But!
    Could I format this as
    (where the symbols are just unique symbols)
    ~~~~~~~~~~~~~
    ªDate - ∞ £ Time ¡ [carriage return]
    Event name
    ~~~~~~~~~~~~~
    and then use a Find/Replace function to tell InDesign
    -  in the case of "  ª . . . ∞  ", apply character style "Date style"
    -  in the case of "  £ . . . ¡ ", apply character style "Time style"
    and then go through and delete all instances of ª, ∞, £ and ¡
    (Extra spaces applied for ease of reading)
    Or, if I'm imagining this wrong, is there another way I can format the original data to automate the application of styles?

    I don't even think you'd need grep for this.
    I'd create two paragraph styles, one for date/time with the next style being event name and event name with the next style being date/time.
    Then create a character style for time and have the base paragraph style for date/time being the formatting you want just for date.
    The date time style would have nested style with none through the hyphen and time through the end of the paragraph.
    Place the text and then select all of it and in the paragraph styles panel right click date/time and from the contextual menu choose apply date/time and next.
    That should fully format all of your text.
    Bob

  • Unable to save paragraph and character styles

    I noticed an issue popping up for me in CS6 yesterday. I thought it was originally because of Fireworks saved PSD but an effort re-create the file from scratch in PS I'm coming across the same issue. In PS when I have a large amount of text layers and create a paragraph or character style, when I have ANY layer/group in my document locked I'm unable to save any paragraph or layer styles. Regardless of the layer or group being locked and regardless of what layer is highlighted I'm unable to save styles / any settings / name etc. The error I get for character styles for example is:
    "Could not complete the Modify Named Character Style command because a specified layer is locked."
    I did notice that in the Fireworks created PSD that without any layer even being locked I'd still get an error. It may be that this other document got some bad mojo from the Fireworks PSD. When creating a test doc and only creating a couple text layers and a bunch of empty groups and layers I'm unable to reproduce this. It appears to happen to me when I have a slew of text layers.
    Has anyone else experienced this and figured out a more solid workaround?

    If you want to add the styles to an already created document:
    1) Create you Character style containing only the character color
    2) Find and Replace, searching for text with red color and replace formatting with the new character style. (Don't type anything in the text part of the Find and Replace dialog)
    3) Create and apply your paragraph style to all. The text with the Character Style applied will stay red.

  • Add a line as part of a character style in InDesign CS4

    Hi all,
    I'm new in InDesign and am in the process to design a 4 pages newsletter for the internal IT dept. of my company.
    Each page (A4) has 2 columns and will contain one or more articles.
    I'd like to create a character style to format the title of each article so it would stand out and include a line underneath the text.
    I had a look at in the underlining options and nearly found what I needed except that I'd like the line to be the same length as the column width and not the same lenght of the text it underlines. So I managed to achieve what I wanted by drawing a line; but is there a way to include that line as part of my "article header" style so I don't have to draw it each time?
    Or maybe there's an option to make the underline longer than the text, but I didn't find it.
    Thanks in advance

    Hi guys and thanks for your super fast answer.
    I'm in ID now and there's no such option in the Paragraph style panel.
    Basically the underlining options in the Paragraph Style window are +/- the same as for the Character Style one.
    Options available are:
    tick box to activate option
    weight
    offset (moves the lines up and down to the text, but doesn't increase the lenght of the underline)
    colour
    type
    The options, tint, overprint stroke, gap colour, gap tint and overprint gap are greyed out for me.
    This is what I want to get. The first line is with the underline option on (line is same lenght as the text)
    Second one is with a line drawn as grahical object.
    So question is: how can i include a line like in the second example in a style so I don't have to draw it each time?

  • Maintaining fill colors in character styles across multiple AI documents

    I'm having a lot of trouble understanding how Adobe Illustrator (CS6) manages character styles imported from different ai documents. If I create all character styles in a single .ai document and only use them in in that document, everything works as expected--colors, fonts, and typography settings are maintained in the character style, and newly added text can be quickly styled with the character style.
    My trouble starts when i want to re-use those character styles in a new .ai document. From the character style menu I use the option to import the character styles from another document, and they import correctly--all of the styles work and style text as expected. But then i save & close the document and re-open it to find that the character style entries are there, but the fills and strokes are all messed up--fonts, sizes, typography settings are maintained, but styles with a blue fill are suddenly filed with black, or some other color.
    So, why is this happening? This happens even if the swatches associated with the character styles are imported to the new document as well. I've read that all character styles are based off of the 'normal' character style. But, i've tried a test making sure that the 'normal' character style was consistent between the two documents and i've still experienced the issue.
    Here's a short video showing the issue i'm experiencing: http://youtu.be/Z-BG7miwib8 (watch at 720p)
    Any insights as to what i'm doing wrong would be GREATLY appreciated.
    Thanks!

    Jamier,
    can you please do the following and report what you see?
    1. Open a blank document
    2. Import a character style
    3. Make a text object and apply the style
    4. Cut and paste the text object inside the document
    5. Save the file
    6. Reopen this file
    Is the character style still intact?
    If so, you could take this way as a bumpy workaround (that should not be required at all, of course).

  • 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.

  • GREP question re: character style

    I am trying to take a block of text and change everything in that text to a certain character style. What's the correct GREP expression to do that? I know I could just highligh the text in question and apply the character style, but I need to use this in a FindChangeByList script, so I need to do it using GREP expressions. Thanks.

    What I'm really looking for is this. When I want to format a paragraph in a paragraph style, sometimes there are underlying character styles that I need to clear first. So I higlight the block of text, go to character styles and select [None], thus clearing that text of any character styles. Then I apply my paragraph style. I've found that if I don't do this, I get unexpected results.
    I know that the active characer styles is always the last character style that was used, but I wish that the default was simply the [None] character style. I'm forever having to go back to [None.]
    I'm trying to build some scripts that automate this for me, but perhaps there's a much easier way to think about this problem.
    Message was edited by: JoJo Jenkins

  • Why do text variables using Running Header character style translate forced returns as a word space in the running head on the first page but close up the space on subsequent pages?

    In an InDesign document that requires 3 different Chapter head paragraph styles (to cope with differrent length headings) I've set up the running heads on the master page with a text variable using the Running header (character style) option. The character style I've assigned to this is an empty character style that is applied to all 3 chapter head paragraph styles.
    Some chapter heads require a forced line break, so that the line breaks are aethesically pleasing. On the first page the text variable translates this forced line break as a word space in the running head, but on subsequent pages it ignores the forced line break. This means that if you have a word space before the forced line break, on the first page you get a double word space and on subsequent pages the running head sets correctly with a single word space. But if you remove the word space before the forced line break in the chapter head text, the first running head sets correctly with forced line break interpreted as a single word space, but on subsequest pages the space is closed up.
    This only seems to be a problem when the character style option is used for header text variables. If a paragraph style is used the forrced line break is interpreted as a a single word space in all instances, both on the foirst page and subsequent pages.
    This would appear to be a bug in how text variables are applied when using the Running header (character style) option. I can't see any other reason why the text variable would beheave differently on the first page and on subsequent pages. There is only one master page, so it isn't a case of their being an error between a main master page and a chapter opener master page.
    Does anyone have any solutionss, or know if this problem has been fixed in subsequent releases of InDesign (I'm using CS6 ID version 8.0)
    Thanks

    Ask in the ID forum...
    Mylenium

  • How can I edit a character style?

    Hi:
    let's see.... I created some character styles but i don't know how to delete or edit. Somebody help me please?
    Sorry my grammar
    Regards from Lima, Perú

    Select the style in the panel, then either double click ther style name, right click and choose Edit Style, or open the panel menu and choose Style Options to edit, or reformat some text using the style to be thway you want it and either right click the style or open the panel menu and choose Redefine style.
    To delete a style you can drag it to the trash icon or use the panel menu. If it's in use you'll be asked to choose a replacement.

  • Help!! Disappearing Character Styles

    I have a strange problem. I have created a Character Style in Pages '09, which I can use when I am in a document, but that style disappears as soon as I close the document. Likewise, even if I keep the original document open, the style is still not visible if I create a new document.
    Does anyone have any thoughts about what I can do?
    Thanks very much.

    It's perfectly normal.
    A style is a document's property, not a program's one.
    In pages 130/131 of the Pages User Guide (English version) we may read:
    *+Importing Styles from Another Document+*
    +When you import a document from Microsoft Word, any styles it contains are imported into the Pages document and can then be used the same way you use any other styles created within Pages.+
    +You can import styles that have already been defined in another Pages document without importing the document’s content.+
    +To import styles from a Pages document:+
    +1 Choose Format > Import Styles.+
    +2 Select the document that contains the styles you want to import, and then click Open.+
    +3 Select the styles you want to import in the dialog. Hold down the Command key as you click the style names to select multiple styles, or click Select All.+
    +4 To replace styles in your document that have the same name as the styles you are importing, select “Replace duplicates.”+
    +Note that replacing a style will affect any text that uses this style. Replacing a style also changes the style of text in locked objects, but the text retains its original appearance.+
    +If an imported style has the same name as a style in the open document and you do+
    +not select “Replace duplicates,” a number is appended to the name of the imported style. For example, if you import a style called Body to a document that already contains a Body style, the imported style will be named Body 2.+
    +5 Click OK.+
    +You can make imported paragraph styles available by clicking the Paragraph Style pop-up menu in the format bar and in the Styles drawer of your document. Imported character and list styles will be available in the Styles drawer.+
    +To maintain a consistent look among several documents, keep a master document that contains all the styles you need. When you need to change a style, change it in the master document and import the master document’s styles into the other documents.+
    Yvan KOENIG (from FRANCE mercredi 14 janvier 2009 12:59:06)

Maybe you are looking for

  • How to connect my friends apple notebook through video call

    HOW TO CONNECT TO A FRIEND WHO IS USING APPLE NOTEBOOK FROM MY IMAC SUGGEST ME WAITING FOR A SOLUTION FROM APPLE TEAM SUPPORT

  • Error while installing RSA connector

    Hi Am installing OIM RSA Authentication manager connector and the installation fails while deploying the connector. Below are the versions used OIM--9.1.0.2 App Server--Jboss-4.2.3.GA OIM RSA Authentication manager connector--9.0.4.12 Below is the er

  • Cable for macbook to tv

    Can somebody please tell me if the Belkin Y Adaptor Cable (http://tinyurl.com/2uzpnb) as sold on the Apple site is the correct cable for connecting the sound for our Macbook to the tv? It's listed as Mfr. Part No.: F8Z180-07-GLD. If not, does Apple s

  • Avg_row_leng in dba_tables

    Hi Can somebody answer my querries Is "avg_row_len" in dba_tables is in Bytes if not then what is its units ??? Will "avg_row_len"*"num_row" give table physically occupied space in terms of bytes in a tablespac ??Thanks in advacne Bye KVSS

  • Using SQL Server 2012 SSIS to Extract Data From SAP

    Hi What is the current best practice for using SQL Server 2012 SSIS to extract data from SAP R3? Please note we are looking for a solution that does not use SAP BW or SAP OHS. Ideally we would like to build our ETL SSIS process to make a .NET call to