#1
|
|||
|
|||
Macro to change specific text styles
Hi,
I would like to create a macro that changes a word into a particular custom style (called 'glossary pop up) the first time it appears under another specific custom style set (called 'page title'). There are a number of 'Page titles' throughout the document and so each new page title I would like the text to change the first time it appears. Is this possible? Thanks |
#2
|
||||
|
||||
You don't need a macro for that - it can be done using just Find/Replace. If you want, though, you could use the macro recorder to record the Find/Replace process as a macro.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Macro options
Hi,
Thanks for your response and apologies for the delay. The reason I wanted the macro is because the word(s) appear multiple times throughout the document and I want them to be a different style the first time they appear under a specific style but not all the times they appear. I am already doing this using find and replace but it takes a while to see if it is the first time it appears under a specific style. I am now thinking that it may be easier to continue to use find and replace for the process itself and then use a macro as a control to check that the text has only been selected once under a particular style. Are you aware if there is a macro I could run to find all instances of a particular style (the styles will be character text rather than paragraph text) under another particular style (which will be a paragraph style) throughout a document? Thanks |
#4
|
||||
|
||||
With the Find/Replace, you specify the Style to find as one of the Find parameters and the replacement Style as another parameter and only do the Replace once. The only time this might be an issue is if you do the Find/Replace, then update the document so that another instance of the word becomes the first instance. You could, of course, record the Find/Replace as a macro but that would only work for that particular word and I gather you have more than one word to find. A Find/Replace macro that processes multiple words could also be written but, unless, you're always working with the same set of words, you then have to consider how the list will be maintained.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro Needed to bold specific lines and Macro to turn into CSV | anewteacher | Word VBA | 1 | 05-28-2014 03:59 PM |
Quickest way to change text to Arial size 11 specific colour | BlueClearSky | Word | 6 | 11-22-2013 03:34 PM |
Why do imported styles not change to default font? | OldGrantonian | Word | 4 | 05-18-2011 06:35 AM |
Need help extracting specific text from one doument to another with macro/VBA. | zsmithku | Word | 1 | 04-15-2011 03:46 PM |
Why can't I change certain styles back to normal? | SuperHans | Word | 1 | 10-16-2009 03:57 AM |