如何实现在WORD文件快速查找某字符串?(50分)

  • 主题发起人 tom12345
  • 开始时间
用查找并替换Word中的字符串
WordDocument1.Range.Find.Execute( FindText, MatchCase, MatchWholeWord,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, GoForward,
Wrap, WordFormat, ReplaceWith, Replace );
 
能否举个例子?
 
你录一段查找字符串的宏就知道了。
 
//替换
procedure replaceword(ts,td:string);
var
FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike,
MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace: OleVariant;
begin
FindText := ts;
MatchCase := False;
MatchWholeWord := True;
MatchWildcards := False;
MatchSoundsLike := False;
MatchAllWordForms := False;
Forward := True;
Wrap := wdFindContinue;
Format := False;
ReplaceWith :=td;
Replace := True;
MainForm.WordDocument.Range.Find.Execute( FindText, MatchCase, MatchWholeWord,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward,
Wrap, Format, ReplaceWith, Replace );
end;
 
WordDocument1.Range.Find.Execute( FindText, MatchCase, MatchWholeWord,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, GoForward,
Wrap, WordFormat, ReplaceWith, Replace );
把replace换成false,ReplaceWith换成‘’就可以了!
 
有人做过Word文件内容的读取吗?如公式怎么保存的
 
同意qdlzq_cn说法,这个功能的确很实用
 
还不如用Delphi内嵌VBA呢

还可以调试

这样写代码除非很简单的,不然调试很困难的
 

Similar threads

顶部