ms-word vba
First written: Jun-2023
last changed Oct-2024
last changed Oct-2024
Steps to create a VBA macro to colourize sentences
The following script can be added to your MS-Word VBA environment in order to quickly change the background colours of each difference sentence in your word documents. This is advantageous if you are reviewing documents and want to be able to visualize lengths or "original versions" of sentences.
Once installed, to run the colourer, simply press sentenceColouringAdd
function.
To undo the highlights, run the sentenceColouringRemove
function.
Installation
In MS-Word
- Press to open the VBA Editor.
- Insert a new module by clicking Insert -> Module.
- Copy and paste the code below into the module window.
vba :: addSentenceColouring
Execution
warningWARNING: Always save your document before you run the macro as unexpected things can always happen.
- In MS-Word, press to open the "Macro" dialog box.
- Select the "sentenceColouringAdd" macro and click the "Run" button.
- Select the "addRepeatedWordHighlights" macro and click the "Run" button.
- All the paragraphs in your document will be colour coded with pale pastel background colours.
To undo:
- In MS-Word, press to open the "Macro" dialog box.
- Select the "sentenceColouringRemove" macro and click the "Run" button.