Skip to main content
December 17, 2013
Question

Remove Character Format Override From Text Range

  • December 17, 2013
  • 1 reply
  • 1969 views

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

This topic has been closed for replies.

1 reply

4everJang
Legend
December 17, 2013

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

December 17, 2013

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

4everJang
Legend
December 17, 2013

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