使用DELPHI控制WORD宏的请教!(菜鸟提问)!!(100分)

  • 主题发起人 主题发起人 spsyd
  • 开始时间 开始时间
S

spsyd

Unregistered / Unconfirmed
GUEST, unregistred user!
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute
(以上是VBA的代码)
如何翻译成DELPHI代码!谢谢!
 
Doc_Handle.Application.Selection.Find.Execute (Replace:=wdReplaceAll);
Doc_Handle.Application.Selection.Find.Execute;

http://www.delphibbs.com/delphibbs/dispq.asp?lid=737517
 
uses Comobj, Word2000;
var
Word_Handle, Doc_Handle: OleVariant;

procedure TForm1.Button1Click(Sender: TObject);
begin
try
Word_Handle := GetActiveOleObject('Word.Application');
except
try
Word_Handle := CreateOleObject('Word.Application');
except
end;
end;

Word_Handle.Visible := True;
Doc_Handle := word_Handle.Documents.open(FileName := 'C:/1.doc', ReadOnly := False, AddToRecentFiles := False);

Doc_Handle.Application.Selection.Find.ClearFormatting;
Doc_Handle.Application.Selection.Find.Replacement.ClearFormatting;
Doc_Handle.Application.Selection.Find.Text:='aaa';
Doc_Handle.Application.Selection.Find.Replacement.Text:='bbb';

Doc_Handle.Application.Selection.Find.Execute(Replace := wdReplaceAll);
Doc_Handle.Application.Selection.Find.Execute;
end;
 
搜索一下以前的贴字
 
解决了没有,我说yzhshi是高手吧,呵呵。
 
客气了,hbezwwl,我听完颜康说起过你,努力吧![:)]
 
接受答案了.
 
后退
顶部