|Adding and removing styles from a document
|Page 1 of 1|
|Author:||phspaelti [ 2018-01-25 00:59:01 ]|
|Post subject:||Adding and removing styles from a document|
Over in another thread Þorvarður asks whether it's possible to remove or add (from some file) styles via macro. The answer is of course yes. But since this is a technical discussion, I'm moving the answer over here.
Removing all styles from a document can be done like this.
But of course this is a bit like taking a sledgehammer to your document. If any styles are actually used, that formatting will vanish.
A more clever way is to remove only the styles not actually used:
This still has one problem, if some of your used styles are based on others that are themselves not used, you might still lose formatting (and you'll change the styles).
So I attach a more elaborate macro here:
The basic idea of the macro is to go through the styles 3 times:
Now to adding styles from another file, for example, one of the files in the Style Library.
For this your best bet is to hard code the file path into the macro, as I have done here. Alternatively one could use a "Choose" command to let the user select the relevant file. [Thanks to Þorvarður for the correction.]
The macro opens the style file (hidden), copies the styles and replaces the ones in the current document. Finally it closes the style file again. The addStyles command allows you to set the style conflict resolution as you would by hand. Here I have chosen the replace option, but rename or ignore are possible as well.
Finally as a variation, I add a macro that lets you choose one of your Style Library files for style import:
|Author:||Þorvarður [ 2018-02-03 04:53:02 ]|
|Post subject:||Re: Adding and removing styles from a document|
This is great. Thank you so much, Philip
I merged the two macros, and I'll be using them a lot. I still have many Nisus Classic documents with old styles that I want to get rid of when I convert them.
Needless to say, these macros would solve the original poster's problem, but I don't think he's listening.
|Page 1 of 1||All times are UTC - 8 hours|
|Powered by phpBB® Forum Software © phpBB Group