iman_a_r
asked on
Find and replace one word in Microsoft Documents With Delphi
Hi all,
I Want an example to find and replace one word of text with the
TwordDocument Class or WordBasic.
Thanks for your help.
I Want an example to find and replace one word of text with the
TwordDocument Class or WordBasic.
Thanks for your help.
d : TWordDocument;
vFindText := source;
vReplaceWith := target;
vMatchCase := true;
vMatchWholeWord := true;
vReplace := wdReplaceAll;
d.Range.Find.Execute( vFindText, vMatchCase, vMatchWholeWord, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, vReplaceWith, vReplace, EmptyParam, EmptyParam, EmptyParam, EmptyParam );
vFindText := source;
vReplaceWith := target;
vMatchCase := true;
vMatchWholeWord := true;
vReplace := wdReplaceAll;
d.Range.Find.Execute( vFindText, vMatchCase, vMatchWholeWord, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, vReplaceWith, vReplace, EmptyParam, EmptyParam, EmptyParam, EmptyParam );
ASKER
This code is that i need ,but it dose not work.
I dont know thats roson.
I dont know thats roson.
ASKER
eugenem , if need any setting to work you'r code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
tell me if this what you need:
uses
ComObj; {se necesita para hacer OLE automation}
procedure TForm1.Button1Click(Sender
//from word to richedit...
begin
MsWord := GetActiveOleObject('Word.B
MsWord.EditSelectAll;
MsWord.EditCopy;
Form1.RichEdit1.PasteFromC
end;
procedure TForm1.Button2Click(Sender
//from richedit to word...
begin
MsWord := GetActiveOleObject('Word.B
Form1.RichEdit1.SelectAll;
Form1.RichEdit1.CopyToClip
MsWord.EditSelectAll;
MsWord.EditPaste;
end;
best regards
Manuel Lopez (lopem)