word 宏代码编写的问题:关于 .Find.Execute replace:=wdReplaceOne , 我在cb写了:Find.OleFunction("Execute", "replace:=wdReplaceOn
楼主zjsxszj(沈智江)2003-11-20 15:47:07 在 C++ Builder / 基础类 提问
Sub replace()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "123456789"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.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
End Sub
String strText = "W";
String strReplaceText = "M";
Variant find = WordApp.Exec(PropertyGet("Selection")).Exec(PropertyGet("Find"));
find.Exec(Procedure("ClearFormatting"));
find.Exec(PropertyGet("Replacement")).Exec(Procedure("ClearFormatting"));
find.Exec(PropertySet("Text")<<strtext.c_str());
find.Exec(PropertyGet("Replacement")).Exec(PropertySet("Text")<<strreplacetext.c_str());
find.Exec(PropertySet("Forward")<<(Variant)true);
find.Exec(PropertySet("Wrap")<<(Variant)1); //wdFindContinue
find.Exec(PropertySet("Format")<<(Variant)false);
find.Exec(PropertySet("MatchCase")<<(Variant)false);
find.Exec(PropertySet("MatchWholeWord")<<(Variant)false);
find.Exec(PropertySet("MatchByte")<<(Variant)true);
find.Exec(PropertySet("MatchAllWordForms")<<(Variant)false);
find.Exec(PropertySet("MatchSoundsLike")<<(Variant)false);
find.Exec(PropertySet("MatchWildcards")<<(Variant)false);
find.Exec(PropertySet("MatchFuzzy")<<(Variant)false);
find.Exec(Function("Execute")<<2);//wdReplaceAll
楼主zjsxszj(沈智江)2003-11-20 15:47:07 在 C++ Builder / 基础类 提问
Sub replace()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "123456789"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.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
End Sub
String strText = "W";
String strReplaceText = "M";
Variant find = WordApp.Exec(PropertyGet("Selection")).Exec(PropertyGet("Find"));
find.Exec(Procedure("ClearFormatting"));
find.Exec(PropertyGet("Replacement")).Exec(Procedure("ClearFormatting"));
find.Exec(PropertySet("Text")<<strtext.c_str());
find.Exec(PropertyGet("Replacement")).Exec(PropertySet("Text")<<strreplacetext.c_str());
find.Exec(PropertySet("Forward")<<(Variant)true);
find.Exec(PropertySet("Wrap")<<(Variant)1); //wdFindContinue
find.Exec(PropertySet("Format")<<(Variant)false);
find.Exec(PropertySet("MatchCase")<<(Variant)false);
find.Exec(PropertySet("MatchWholeWord")<<(Variant)false);
find.Exec(PropertySet("MatchByte")<<(Variant)true);
find.Exec(PropertySet("MatchAllWordForms")<<(Variant)false);
find.Exec(PropertySet("MatchSoundsLike")<<(Variant)false);
find.Exec(PropertySet("MatchWildcards")<<(Variant)false);
find.Exec(PropertySet("MatchFuzzy")<<(Variant)false);
find.Exec(Function("Execute")<<2);//wdReplaceAll