Re:CL - Word97 - mailmerge
Quote
"Kees Lagendijk" <k...@REMOVETHIScasema.net> wrote:
>>>I have succeeded in automating a mailmerge from within D3 (using
>>>word_tlb.pas).
>>>However, I would like to close the main document after merging the data.
>>>Does anyone know what I am talking about?
>>Do you want to save the main document with or without changes?
>without the changes !
The following closes Word without saving changes.
========
// global variables
var
WordApp: _Application;
{$IFDEF VER100}
EmptyParam: OleVariant;
{$ENDIF}
// quit Word without saving changes
procedure TForm1.FormDestroy(Sender: TObject);
var
SaveChanges: OleVariant;
begin
try
if Assigned(WordApp) then
begin
SaveChanges := wdDoNotSaveChanges;
WordApp.Quit(SaveChanges, EmptyParam, EmptyParam);
end;
except
// just get out of here - too late to do anything else.
end;
end;
initialization
{$IFDEF VER100}
TVarData(EmptyParam).VType := varError;
TVarData(EmptyParam).VError := DISP_E_PARAMNOTFOUND;
{$ENDIF}
end.
========
// close a document without saving changes
var
SaveChanges: OleVariant;
aDoc: _Document;
SaveChanges := wdDoNotSaveChanges;
aDoc.Close(SaveChanges, EmptyParam, EmptyParam);
========
--
Regards,
Chris Roberts