Board index » delphi » Open/Close/Open Word Documents

Open/Close/Open Word Documents

Hi all,

    I'm using D5 TWordApplication and TWordDocument in my app.

    I open a document wihout any problem using a dialog I wrote. To
close it I use:

procedure TEscrAutomForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  WordDocument1.Disconnect;
  WordApplication1.Disconnect;
  WordApplication1.Quit;
end;

When I Show the same dialog (form) again, and I try to open other doc in
the same way as before:

WordApplication1.Connect ;
  WordDocument1.ConnectTo(WordApplication1.Documents.Open(ModelFileName,
EmptyParam,
    EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam,
    EmptyParam, EmptyParam));

I have an error related with RPC

Any idea or sugestion? Am I using a wrong programming practice?

Thank you in advance!

 

Re:Open/Close/Open Word Documents


<<Elias Todorovich:
  WordApplication1.Disconnect;
  WordApplication1.Quit;

Quote

Those commands are in the wrong order. The first line
disconnects the WordApplication1 component from Word. In
order to call Word's Quit method, the component must be
connected to Word - so it simply reconnects, and stays
connected - not good. :) Always Disconnect /after/
Quitting.

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads