BK Guest
|
Posted: Tue Dec 09, 2003 9:46 pm Post subject: Word Automation with TWordApplication and TWordDocument |
|
|
Hi Deborah,
After going through all the listings here and also
http://www.djpate.freeserve.co.uk/Automation.htm site which you have
provided, tried using the same sample for word, using Delphi 6.
Rest of the things work gr8! But replace functionality gives a problem while
replacing a specific word in the document.
Following is the same procedure from example.
procedure TMain.ReplaceBtnClick(Sender: TObject);
var
SearchText, ReplaceText, Wrap, All: OleVariant;
TextRange: Range;
begin
{ Replace text }
SearchText := 'pathetic';
ReplaceText := 'marvellous';
Wrap := wdFindContinue;
All := wdReplaceAll;
Doc.Content.Find.ExecuteOld(SearchText, EmptyParam, EmptyParam,
EmptyParam,
EmptyParam, EmptyParam, EmptyParam, Wrap,
EmptyParam, ReplaceText, All);
{ Find text and format it. This time we define our own range, so that
it can be redefined when the Find is executed. }
TextRange := Doc.Content;
SearchText := 'lorem ipsum dolor';
TextRange.Find.ExecuteOld(SearchText, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, Wrap,
EmptyParam, EmptyParam, EmptyParam);
TextRange.Font.Italic := integer(True);
end;
it gives an error as "The Stub return bad data" and after that keeps giving
AV.
Can u suggest anything?
Appreciate your help!
Thanks
|
|