大家在用word写文章时,有时候需要复制一些以前写好的文章,这时候就需要替换图中的序号,如果一个一个的重新排列图号,是非常麻烦的事情,所以,我编辑了一个“宏”,到时用宏命令替换就可以了
附:宏命令内容如下。
Sub 替换()
'
' 替换 Macro
' 宏在 2007-4-19 由 王春海 录制
'
For i = 11 To 29
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "图9-" & i
.Replacement.Text = "图5-" & (i + 2)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next i
End Sub
'
' 替换 Macro
' 宏在 2007-4-19 由 王春海 录制
'
For i = 11 To 29
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "图9-" & i
.Replacement.Text = "图5-" & (i + 2)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next i
End Sub
介绍,上面的示例中,将把从图9-11~图9-29替换成图5-13~图5-31.
如果有递减的替换,例如下面的例子,将把从图9-100~图9-120替换成图5-80~图5-100.
Sub 替换()
'
' 替换 Macro
' 宏在 2007-4-19 由 演示人 录制
'
For i = 100 To 120
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "图9-" & i
.Replacement.Text = "图5-" & (i- 20)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next i
End Sub
'
' 替换 Macro
' 宏在 2007-4-19 由 演示人 录制
'
For i = 100 To 120
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "图9-" & i
.Replacement.Text = "图5-" & (i- 20)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next i
End Sub