I want to turn all numbers in a pre-selected paragraph into superscript font without changing the numbers in the rest of the document.
I do not know Visual Basic (yet!) so use Record a Macro. I do the necessary ReplaceAll which only affects the previously selected text, answer "No" when it asks if this should be applied to rest of document then stop macro recording. All is well -selected text has been changed as required, rest of text left unaltered.
However, when macro is run it changes all the numbers in the whole document to superscript, not just those in the selected text.
How do I get the macro to only apply to the text I have selected before running it. As I said, what I do works fine during the recording of the macro!
Sub supernos() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find.Replacement.Font .Superscript = True End With With Selection.Find .Text = "[0-9]" .Replacement.Text = "" .Forward = True .Wrap = wdFindAsk .Format = True .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll End Sub
After reading your second posting when you said it worked for you, I thought I would just try the macro (unaltered)once again on the same file, same bit of text and this time, much to my surprise as I had earlier spent 45 mintues with it not doing its thing, it worked! I had, however, rebooted the PCC in between originally trying to get macro to work and reading your second posting. I too am baffled - perhaps something odd glitch happened with Word or Office and rebooting sorted it out.
I am sorry to have wasted your time - thank you for pointing me to the help file on selection - I will get to grips with it in due course.
This thread is now locked and can not be replied to.