Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-30-2020, 07:00 AM
Jage Jage is offline Trouble highlighting all instances of superscript text Mac OS X Trouble highlighting all instances of superscript text Office 2016 for Mac
Novice
Trouble highlighting all instances of superscript text
 
Join Date: Mar 2020
Posts: 2
Jage is on a distinguished road
Default Trouble highlighting all instances of superscript text

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

Reply With Quote
  #2  
Old 03-30-2020, 01:56 PM
macropod's Avatar
macropod macropod is offline Trouble highlighting all instances of superscript text Windows 7 64bit Trouble highlighting all instances of superscript text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,339
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

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
[MS MVP - Word]
Reply With Quote
  #3  
Old 03-30-2020, 11:54 PM
Jage Jage is offline Trouble highlighting all instances of superscript text Mac OS X Trouble highlighting all instances of superscript text Office 2016 for Mac
Novice
Trouble highlighting all instances of superscript text
 
Join Date: Mar 2020
Posts: 2
Jage is on a distinguished road
Default

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.
Reply With Quote
Reply

Tags
vba code, word 16

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble highlighting all instances of superscript text Footnote reference numbers precede by superscript '(' and follow w/ superscript ')' Swarup Word 4 07-18-2019 05:51 PM
Trouble highlighting all instances of superscript text Unwanted text highlighting AllusiveKitten Word 2 07-20-2015 04:00 PM
Trouble highlighting all instances of superscript text 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

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 09:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft