T
Tarallen
Hello,
I created a macro that would remove the word "Figure," the figure number,
and the period that follows it in a caption. I just want the caption without
"Figure #-#" before it. The problem is, obviously, that the number is a field
code, not a fixed number.
I tried recording a macro that searched for "Figure ^#-^#. " and replaced it
with nothing. It worked fine when I practiced it manually using the Find and
Replace feature in Word. However, when I tried to record it, suddenly, it
would not find any instances of "Figure ^#-^#. "
Despite the difficulty with recording it the way I wanted it, I modified the
macro to accomplish this, but it is still not working. So, my guess is it's
something to do with the field codes. But why would it work manually and not
as part of the macro? And how do I fix it? Thanks, in advance, for any help
you can give me.
The macro is below.
Sub RemoveFigure()
'
' RemoveFigure Macro
' Macro recorded 11/20/2006 by TAllen.
' "&chr(10)&"Removes all instances of "Figure," the figure number and the
period and space before the text.
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Figure ^#-^#. "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
I created a macro that would remove the word "Figure," the figure number,
and the period that follows it in a caption. I just want the caption without
"Figure #-#" before it. The problem is, obviously, that the number is a field
code, not a fixed number.
I tried recording a macro that searched for "Figure ^#-^#. " and replaced it
with nothing. It worked fine when I practiced it manually using the Find and
Replace feature in Word. However, when I tried to record it, suddenly, it
would not find any instances of "Figure ^#-^#. "
Despite the difficulty with recording it the way I wanted it, I modified the
macro to accomplish this, but it is still not working. So, my guess is it's
something to do with the field codes. But why would it work manually and not
as part of the macro? And how do I fix it? Thanks, in advance, for any help
you can give me.
The macro is below.
Sub RemoveFigure()
'
' RemoveFigure Macro
' Macro recorded 11/20/2006 by TAllen.
' "&chr(10)&"Removes all instances of "Figure," the figure number and the
period and space before the text.
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Figure ^#-^#. "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub