终于弄出来了。不用演示实例了!
//通配符
procedure TMainForm.Button2Click(Sender: TObject);
var
lSelection, lFind: DispatchHelper;
//lFound bject;
begin
lSelection := DispatchHelper.Create(FApp.PropertyGet('Selection', []));
lFind := DispatchHelper.Create(lSelection.PropertyGet('Find', []));
//注意里面的参数,具体查ms的帮助
lFind.InvokeMethod('Execute', ['[<]-*-[>]', False, true, true, false, False, True, 1, False,'',
0, False, False, False, False]);
// MyWord.Selection.Find.Execute(Replace:=wdReplaceAll, forward:= True, Wrap := wdFindContinue, MatchWildcards := false);
while objecthelper.ToBoolean(lFind.PropertyGet('Found',[])) do
begin
//获取值
dialogs.ShowMessage(objecthelper.ToString(lSelection.PropertyGet('Text',[])));
lSelection.PropertyPut('Text',['lj']);
//设置值
lFind.InvokeMethod('Execute', ['[<]-*-[>]', False, true, true, false, False, True, 1, False,'',
0, False, False, False, False]);
end;
//vba
// Function Execute([FindText], [MatchCase], [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [MatchAllWordForms], [Forward], [Wrap], [Format], [ReplaceWith], [Replace], [MatchKashida], [MatchDiacritics], [MatchAlefHamza], [MatchControl]) As Boolean
// Word.Find 的成员
end; |