在Delphi中使用Word对象,如何使用wdPeplaceAll等VBA自带的常量,以及如何转换
wApp.Selection.Find.ClearFormatting;
wApp.Selection.Find.Replacement.ClearFormatting;
wApp.Selection.Find.Text:=docText;
wApp.Selection.Find.Replacment.Text:=newText;
wApp.Selection.Find.Forward:=True;
wApp.Selection.Find.Wrap:=wdFindContinue;
wApp.Selection.Find.Format:=False;
wApp.Selection.Find.MatchCase:=False;
wApp.Selection.Find.MatchWholeWord:=True;
wApp.Selection.Find.MatchByte:=True;
wApp.Selection.Find.MatchWildcards:=False;
wApp.Selection.Find.MatchSoundsLike:=Fasle;
wApp.Selection.Find.MatchAllWordForms:=Fasle;
wApp.Selection.Find.Execute(Replace:=wdReplaceAll);
等
wdReplaceAll,wdFindContinue均提示有错
已经Uses COMOBJ
[解决办法]
安装Word程序
然后: "工具 "- "宏 "- "Visual Basic "编辑器
然后: "视图 "- "对象浏览器 "
然后选择 "所有库 "选项,然后输入你想要查看的常量名如:wdReplaceAll
在对象浏览器的最下方你能看到每个常量的数值
祝你好运