借用您的地方我也提个问题:
就是将WORD中的多个特定符号一起替换的问题,当然可以用宏来实现,但是我没有用宏,我用ole来实现的,见下面的代码!!!在运行中出现一个问题,就是该段程序不能替换掉所有的特定符号(本文中为[JBWH]),只能替换掉第一个,不知道为什么,请大家帮帮忙!!
procedure TForm1.Button4Click(Sender: TObject);
var
FindText,WordObject, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike,
MatchAllWordForms, Forward1, Wrap, Format, Replacewith, Replaceall: OleVariant;
begin
FindText := '[JBWH]';//被替换字符
MatchCase := False;
MatchWholeWord := True;
MatchWildcards := False;
MatchSoundsLike := False;
MatchAllWordForms := False;
Forward1 := True;
Wrap := wdFindContinue;
Format := False;
ReplaceWith := '举交字第001号';//替换字符
Replaceall := True;
WordObject:=CreateOLEObject('Word.Application');
WordObject.Visible := True;
try
WordObject.Documents.open('d:/111.doc',true);
WordObject.Application.ActiveDocument.Range.Find.Execute( FindText, MatchCase, MatchWholeWord,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward1,
Wrap, Format, ReplaceWith, Replaceall );
finally
WordObject.Application.ActiveDocument.SaveAs('d:/aa.doc',wdFormatDocument);
end;
end;