5 Replies Latest reply: Dec 18, 2013 10:05 AM by 4everJang RSS

    Remove Character Format Override From Text Range

    mdver Community Member

      This should be simple, but I am wracking my brains trying to figure this out.

       

      I simply want to take a text range and remove any character format override (CTRL-I or CTRL-O) and remove the override. I am thinking I need to create a special PropVal variable, but I am trying to figure out how to do this properly.

       

      Thanks,

      Marc

        • 1. Re: Remove Character Format Override From Text Range
          4everJang Community Member

          Marc,

           

          If you simply want to remore all overrides (i.e. not change the current overrides to existing formats), there is a much simpler and faster method. To explain this, you need to know about the Import Formats function. Please open the command File > Import > Formats and look at the dialog. Select all the formats you want to remove the overrides for and select the option for "While Updating, Remove: Other Formats/Layout Overrides". The listbox "Import from Document" shows the current document by default, which is what you want to do. This effectively removes overrides without doing anything else (as the formats are overwritten by the formats from the same document, which changes nothing to them).

           

          Translated into ExtendScript code, this is what it looks like:

           

          var oDoc = app.ActiveDoc;

          oDoc.SimpleImportFormats ( oDoc, Constants.FF_UFF_FONT | Constants.FF_UFF_REMOVE_EXCEPTIONS );

           

          If you also want to remove paragraph format overrides, add Constants.FF_UFF_PGF. Make sure to use a single pipe ( | ) symbol to create a bitwise OR on the constants, as using a double pipe ( || ) is a logical OR and will leave you stunned.

           

          Kind regards

           

          Jang

          • 2. Re: Remove Character Format Override From Text Range
            mdver Community Member

            I tried to use this technique, both code-wise and using the menu, and the character format overrides are not in fact removed.

             

            I would really prefer not to do it this way, though, because I need much more control over when I remove character format overrides. There may be other cases I will have to later handle, and do not want to remove overrides unless I know in a specific case I want to.

             

            Something strange, though, is that even when I use find/replace to remove character format overrides it apparently removes the override itself, but somehow the effect of the override remains. I still need to remove the effect (which I don't understand, given that removing the override should remove the effect). If I use find/change to look for the character format and change to another format (specifying everything As Is except specifically what I want to change), then I am able to remove the effect.

             

            Thanks,

            Marc

            • 3. Re: Remove Character Format Override From Text Range
              4everJang Community Member

              Hi Marc,

               

              It should really work via the menu if you use the Remove Overrides option, otherwise there may be a character format you do not know about (possibly applied via the EDD ?). If you cannot remove the overrides this way, it may not be possible to remove them by a script either.

               

              I do understand you want to do it range by range, though. Are you going to remove all character formats from the paragraphs or just remove the overrides while keeping the character formats that were applied?

               

              Ciao

               

              Jang

              • 4. Re: Remove Character Format Override From Text Range
                mdver Community Member

                We don't use structured Framemaker here, so I don't see how EDD would be applicable. I did check and as far as anyone knows we don't use anything like EDDs.

                 

                The idea is to convert from overrides to proper character formats. I only want to remove overrides and their effects. Any character formats should remain applied as they are.

                • 5. Re: Remove Character Format Override From Text Range
                  4everJang Community Member

                  OK, but with no EDD there is no reason that the character format overrides cannot be removed using the Import Formats function. But as you want to convert the overrides, that would not help you, anyway.

                   

                  If you can send me a sample document I will have a look at and see if I can create the script for you. It should not be too difficult. The main trick is in finding the sections with the overrides and there are several ways to do this. I don't trust the Find method all too much, so I would move from one paragraph to the next and use GetText to retrieve the sections with character overrides. Ones you have those, it is a walk in the park.

                   

                  Kind regards

                   

                  Jang (my mail adress is jang at jang dot nl)