M
mylemontree
Unregistered / Unconfirmed
GUEST, unregistred user!
我在原来的帖子中找到,这样一段代码:
/replace a specified string
procedure TForm1.Button4Click(Sender: TObject);
var
FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike,
MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace: OleVariant;
begin
FindText := '<#Name>';//待替换字符串
MatchCase := False;
MatchWholeWord := True;
MatchWildcards := False;
MatchSoundsLike := False;
MatchAllWordForms := False;
Forward := True;
Wrap := wdFindStop;
Format := False;
ReplaceWith := 'Delphi';//替换后的字符串
Replace := wdReplaceAll;
WordDocument1.Range.Find.Execute(FindText, MatchCase, MatchWholeWord,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward,
Wrap, Format, ReplaceWith, Replace);
end;
但在我的程序中实际RUN时,没有替换特定的字符串,而是新建了一个WORD文档,WHY
/replace a specified string
procedure TForm1.Button4Click(Sender: TObject);
var
FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike,
MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace: OleVariant;
begin
FindText := '<#Name>';//待替换字符串
MatchCase := False;
MatchWholeWord := True;
MatchWildcards := False;
MatchSoundsLike := False;
MatchAllWordForms := False;
Forward := True;
Wrap := wdFindStop;
Format := False;
ReplaceWith := 'Delphi';//替换后的字符串
Replace := wdReplaceAll;
WordDocument1.Range.Find.Execute(FindText, MatchCase, MatchWholeWord,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward,
Wrap, Format, ReplaceWith, Replace);
end;
但在我的程序中实际RUN时,没有替换特定的字符串,而是新建了一个WORD文档,WHY