![]() |
|
|
|
#1
|
|||
|
|||
|
Hi everyone.
My apologies for the newbie question. I would like to highlight all instances of superscript text in a Word document. I have got as far as the following code but it doesn't seem to be working. Does anyone have any tips on what I am missing here? Many thanks! Code:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = True
Options.DefaultHighlightColorIndex = wdYellow
Selection.Range.HighlightColorIndex = wdYellow
With Selection.Find
.Font.Superscript = True
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
|
|
#2
|
||||
|
||||
|
One wonders why you'd record a macro for such a simple thing. That said, try:
Code:
Sub Demo() Options.DefaultHighlightColorIndex = wdYellow With ActiveDocument.Range.Find .ClearFormatting .Replacement.Highlight = True .Font.Superscript = True .Replacement.Text = "^&" .Forward = True .Wrap = wdFindContinue .Format = True .Execute Replace:=wdReplaceAll End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Hi macropod,
Many thanks. That works and is a lot simpler than other snippets of code I have found online. I need to highlight a number of particular characters that have different styling/fonts, and I think I can now use your code to chain together a search for these. So thanks again; that's very helpful. |
|
| Tags |
| vba code, word 16 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Footnote reference numbers precede by superscript '(' and follow w/ superscript ')'
|
Swarup | Word | 4 | 07-18-2019 05:51 PM |
Unwanted text highlighting
|
AllusiveKitten | Word | 2 | 07-20-2015 04:00 PM |
Find superscript numbers with a prefix of some default text
|
AlexandarR | Word | 7 | 05-20-2015 07:57 AM |
| Highlighting multiple word instances in text | gekser | Word VBA | 9 | 07-10-2014 05:46 AM |
| Text Highlighting in Yellow ??? | mark4man | Publisher | 0 | 12-15-2005 06:46 PM |