Board index » delphi » How call a Word document inside Delphi

How call a Word document inside Delphi

Anybody can say me how can i open an Word document while executing a
Delphi application? I want:

1o) Start application;
2o) Invoque a document ( for example, with a button)
3o) Display the document
4o) Close the document and resume the application

Thanks

Jorge

 

Re:How call a Word document inside Delphi


If you go to http://www.inprise.com/delphi/papers/microexce/ there is a
paper by Charlie Calvert titled 'Delphi and Microsoft Office:
Automating Excel and Word' that shows how to use variants and iDispatch.

In article <380ECBDD.75B5D...@mail.telepac.pt>,
  Jorge <j...@mail.telepac.pt> wrote:

Quote
> Anybody can say me how can i open an Word document while executing a
> Delphi application? I want:

> 1o) Start application;
> 2o) Invoque a document ( for example, with a button)
> 3o) Display the document
> 4o) Close the document and resume the application

> Thanks

> Jorge

Sent via Deja.com http://www.deja.com/
Before you buy.

Re:How call a Word document inside Delphi


you must use OLE

ex:

procedure aaa;
var  MsWord    : OLEVariant;
begin

      MsWord :=CreateOleObject('Word.Application');
      MsWord.visible:=visible;
      MsWord.Documents.Open(FileName:='c:\a.doc');
...
...
  MsWord.Quit(savechanges:=false); // don't save the changes in the
documents
  MsWord := UnAssigned;
end;

Jorge <j...@mail.telepac.pt> a crit dans le message :
380ECBDD.75B5D...@mail.telepac.pt...

Quote
> Anybody can say me how can i open an Word document while executing a
> Delphi application? I want:

> 1o) Start application;
> 2o) Invoque a document ( for example, with a button)
> 3o) Display the document
> 4o) Close the document and resume the application

> Thanks

> Jorge

Re:How call a Word document inside Delphi


you must use OLE

ex:

procedure aaa;
var  MsWord    : OLEVariant;
begin

      MsWord :=CreateOleObject('Word.Application');
      MsWord.visible:=True;  //// the mistake is here
      MsWord.Documents.Open(FileName:='c:\a.doc');
...
...
  MsWord.Quit(savechanges:=false); // don't save the changes in the
documents
  MsWord := UnAssigned;
end;
Jorge <j...@mail.telepac.pt> a crit dans le message :
380ECBDD.75B5D...@mail.telepac.pt...

Quote
> Anybody can say me how can i open an Word document while executing a
> Delphi application? I want:

> 1o) Start application;
> 2o) Invoque a document ( for example, with a button)
> 3o) Display the document
> 4o) Close the document and resume the application

> Thanks

> Jorge

Re:How call a Word document inside Delphi


the communts are in french but it works

do you know how to create a Word Document ?
assigne(F,'c:\file.doc).... ????

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////
procedure OuvreWord(nomFichier: String);
{Effet   : Ouvre Micorosoft Word avec le fichier re?u en param. S'il
n'existe pas
         , propose de le crer et de l'ouvrir
 ParamIn : Nom du fichier ex. NomFile.doc  }
var word: variant;
begin
     word:= CreateOLEObject('Word.Application');
     try
        word.WordBasic.FileOpen(pathImmo+'Docu\' +nomFichier);
     except
           on EOleError do  {si fichier pas trouv}
           begin
                if MessageDlg('Le dossier slectionn ne possde pas de
dossier.'+ #10#13
                              +'Voulez-vous en cre un
?',mtConfirmation,mbOKCancel,0) = mrOk then
                begin
                   {cre un fichier et recommnencer ???}

                end else Exit;
           end;
     end;
     word.wordBasic.AppShow;
end;////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////

Jorge <j...@mail.telepac.pt> a crit dans le message :
380ECBDD.75B5D...@mail.telepac.pt...

Quote
> Anybody can say me how can i open an Word document while executing a
> Delphi application? I want:

> 1o) Start application;
> 2o) Invoque a document ( for example, with a button)
> 3o) Display the document
> 4o) Close the document and resume the application

> Thanks

> Jorge

Re:How call a Word document inside Delphi


<<Jorge:
 Anybody can say me how can i open an Word document while executing a
Delphi application? I want:

1o) Start application;
2o) Invoque a document ( for example, with a button)
3o) Display the document
4o) Close the document and resume the application

Quote

Code for all for steps is shown on my web site:
http://www.djpate.freeserve.co.uk/Automation.htm

Deborah Pate

Other Threads