![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I have the macro here below to change superscripts to regular text except for footnote marks. It works OK, but now I need the same result without using 'Selection'. Can someone help? Thanks!
Quote:
|
|
#2
|
|||
|
|||
|
Hi, RobiNew! Just replace selection with ActiveDocument.range:
Code:
Sub Macro()
Dim oRng As range
Set oRng = ActiveDocument.range
oRng.Find.ClearFormatting
With oRng.Find.Font
.Superscript = True
End With
oRng.Find.Replacement.ClearFormatting
With oRng.Find.Replacement.Font
.Superscript = False
End With
oRng.Find.Execute Replace:=wdReplaceAll
End Sub
|
|
#3
|
|||
|
|||
|
Thanks a lot, Vivka! That's very instructive. Can you modify the code so as to leave superscript footnote marks unchanged? This is what I need. Thanks again!
|
|
#4
|
|||
|
|||
|
I didn't check it, but hopefully it will work properly:
Code:
Sub Macro()
Dim oRng As range
Set oRng = ActiveDocument.StoryRanges(1)
oRng.Find.ClearFormatting
With oRng.Find.Font
.Superscript = True
End With
oRng.Find.Replacement.ClearFormatting
With oRng.Find.Replacement.Font
.Superscript = False
End With
oRng.Find.Execute Replace:=wdReplaceAll
set oRng = Nothing
End Sub
|
|
#5
|
|||
|
|||
|
Thanks, but this not what I need. There are texts in which superscript occurs in the text and in the footnotes. In these words and sentences I want to change superscript to normal. However, both in the text and the foonotes I want to leave the footnote marks unchanged (that is: superscript). All this I achieved with the code I originally posted, but now I need the same result without using 'Selection'.
|
|
#6
|
|||
|
|||
|
The code in post 4 should change superscripts in the main text leaving footnotes intact. And this is the fastest way (as far as I know).
But (just in case) try this one. It doesn't use With...End With block: Code:
Sub Superscripts_To_Regular_MainTxt()
'Change all superscripts to normal text only in wdMainTextStory (1).
For Each aStory In ActiveDocument.StoryRanges
If aStory.StoryType = wdMainTextStory Then aStory.Font.Superscript = False
Next aStory
End Sub
|
|
#7
|
|||
|
|||
|
It is really very simple. Just replace Selection with the range you want to find in. For example ActiveDocument.Content which is the same as the MainStory:
Code:
Sub ReplaceSuperscript()
With ActiveDocument.Content.Find
.ClearFormatting
With .Font
.Superscript = True
.Subscript = False
End With
.Replacement.ClearFormatting
With .Replacement.Font
.Superscript = False
.Subscript = False
End With
.Text = "[!^02]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End Sub
Code:
Sub ReplaceSuperscript()
Dim story As Range
For Each story In ActiveDocument.StoryRanges
With story.Find
.ClearFormatting
With .Font
.Superscript = True
.Subscript = False
End With
.Replacement.ClearFormatting
With .Replacement.Font
.Superscript = False
.Subscript = False
End With
.Text = "[!^02]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
Next story
End Sub
|
|
#8
|
|||
|
|||
|
Thanks a lot, Italophile! Your second code is exactly what I need. Thanks again!
|
|
| Tags |
| replace, superscript |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Loop through Footnote Reference Marks
|
Ramses505 | Word VBA | 6 | 09-21-2023 12:10 AM |
Macro to change font size of Footnote Reference in Footnote Text
|
TheBigBoss | Word VBA | 5 | 06-10-2022 06:14 AM |
| Need to change superscripts to regular text but also add parentheses | DCabby | Word VBA | 4 | 11-13-2019 09:43 AM |
Convert endnote/footnote to regular text
|
Cobb78 | Word | 5 | 07-11-2016 06:23 AM |
Regular (roman) character style doesn't change text to roman
|
kcbenson | Word | 2 | 10-16-2014 01:31 PM |