主题:由WORD宏命令改作VFP命令,为什么达不到预期效果???
Sub Macro1()
'
' Macro1 Macro
' 宏在 2010-11-20 由 微软用户 录制
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "标 题"
.Replacement.Text = "标题内容"
.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
End Sub
上面是我在WORD中录制的一段查找、替换的宏命令,将其改作VFP命令如下:
(本人通过建立对象“OLE”打开WORD文档)
OLE.Selection.Find.ClearFormatting
OLE.Selection.Find.Replacement.ClearFormatting
With OLE.Selection.Find
.Text = "标 题"
.Replacement.Text = "标题内容"
.Forward = .T.
.Wrap = 1 && wdFindContinue=1
.Format = .F.
.MatchCase = .F.
.MatchWholeWord = .F.
.MatchByte = .T.
.MatchWildcards = .F.
.MatchSoundsLike = .F.
.MatchAllWordForms = .F.
EndWith
OLE.Selection.Find.Execute(2) &&wdReplaceAll=2
在WORD中运行宏时,可将“标 题”替换为“标题内容”,而在VFP下执行由WORD宏命令改写的VFP命令时,只是找到“标 题”,但未将其替换为“标题内容”。请问:
1.是什么原因导致不能替换???
2.将WORD宏命令:Selection.Find.Execute Replace:=wdReplaceAll
改作VFP命令:OLE.Selection.Find.Execute(2) &&wdReplaceAll=2
正确与否???
请赐教
谢谢!!!
'
' Macro1 Macro
' 宏在 2010-11-20 由 微软用户 录制
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "标 题"
.Replacement.Text = "标题内容"
.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
End Sub
上面是我在WORD中录制的一段查找、替换的宏命令,将其改作VFP命令如下:
(本人通过建立对象“OLE”打开WORD文档)
OLE.Selection.Find.ClearFormatting
OLE.Selection.Find.Replacement.ClearFormatting
With OLE.Selection.Find
.Text = "标 题"
.Replacement.Text = "标题内容"
.Forward = .T.
.Wrap = 1 && wdFindContinue=1
.Format = .F.
.MatchCase = .F.
.MatchWholeWord = .F.
.MatchByte = .T.
.MatchWildcards = .F.
.MatchSoundsLike = .F.
.MatchAllWordForms = .F.
EndWith
OLE.Selection.Find.Execute(2) &&wdReplaceAll=2
在WORD中运行宏时,可将“标 题”替换为“标题内容”,而在VFP下执行由WORD宏命令改写的VFP命令时,只是找到“标 题”,但未将其替换为“标题内容”。请问:
1.是什么原因导致不能替换???
2.将WORD宏命令:Selection.Find.Execute Replace:=wdReplaceAll
改作VFP命令:OLE.Selection.Find.Execute(2) &&wdReplaceAll=2
正确与否???
请赐教
谢谢!!!