B
Blue_Fire
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的代码1是word97宏生成的,目的是将文档中的huang全部替换为wang,我现在想在delphi里实现这个功能,
代码2是经过转换后的,但是看不到运行效果(能够查找,但是没法替换),请教!
代码1
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "huang"
.Replacement.Text = "wang"
.Forward = True
.Wrap = 1
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.MatchByte = True
End With
Selection.Find.Execute Replace:=2
代码2
uses ComObj
var
word_handleleviarant;
procedure form1.button1click(sender:Tobject);
begin
word_handle.Selection.Find.ClearFormatting; //清空待查字符串输入框
word_handle.Selection.Find.Replacement.ClearFormatting; //清空替换字符串输入框
word_handle.selection.find.Text = "huang"; //设置待查字符串
word_handle.selection.find.Replacement.Text = "wang"; //设置替换字符串
//其他查找属性
word_handle.selection.find.Forward = True;
word_handle.selection.find.Wrap = 1;
word_handle.selection.find.Format = False;
word_handle.selection.find.MatchCase = False;
word_handle.selection.find.MatchWholeWord = False;
word_handle.selection.find.MatchWildcards = False;
word_handle.selection.find.MatchSoundsLike = False;
word_handle.selection.find.MatchAllWordForms = False;
word_handle.selection.find.MatchByte = True;
//执行全部替换动作
word_handle.selection.find.Execute(2);
end;
代码2是经过转换后的,但是看不到运行效果(能够查找,但是没法替换),请教!
代码1
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "huang"
.Replacement.Text = "wang"
.Forward = True
.Wrap = 1
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.MatchByte = True
End With
Selection.Find.Execute Replace:=2
代码2
uses ComObj
var
word_handleleviarant;
procedure form1.button1click(sender:Tobject);
begin
word_handle.Selection.Find.ClearFormatting; //清空待查字符串输入框
word_handle.Selection.Find.Replacement.ClearFormatting; //清空替换字符串输入框
word_handle.selection.find.Text = "huang"; //设置待查字符串
word_handle.selection.find.Replacement.Text = "wang"; //设置替换字符串
//其他查找属性
word_handle.selection.find.Forward = True;
word_handle.selection.find.Wrap = 1;
word_handle.selection.find.Format = False;
word_handle.selection.find.MatchCase = False;
word_handle.selection.find.MatchWholeWord = False;
word_handle.selection.find.MatchWildcards = False;
word_handle.selection.find.MatchSoundsLike = False;
word_handle.selection.find.MatchAllWordForms = False;
word_handle.selection.find.MatchByte = True;
//执行全部替换动作
word_handle.selection.find.Execute(2);
end;