Board index » delphi » Word2000 Automation + D5

Word2000 Automation + D5

Hi,
It should be easy... I'm trying to open a word 2000 file, print it, and
close it.

I'm using this:

var
 WordObj : Variant;
    .
    .
    .
try
     WordObj := CreateOleObject('Word.Application');
except
        ShowMessage('N?o foi possvel iniciar o MS Word.');
        Exit;
end;
WordObj.visible:=true;
WordObj.Documents.Open('DocumentName');
WordObj.Documents('DocumentName').Activate;
// At this point I get an error: 'Documents' is'nt a method !!! How can I
activate the documento to then print  and close it??
WordObj.ActiveDocument.PrintOut;
WordObj.documents(1).close;
WordObj.FileCloseAll;
WordObj.nothing;

Thanks

David Gurevitz

 

Re:Word2000 Automation + D5


<<David Gurevitz:
// At this point I get an error: 'Documents' is'nt a method
!!!

Quote

You can access documents by name like this:
var
  Doc: variant;
..
  Doc := Word.Documents.Item('DocName');

However in your case you can skip that and assign the variable
directly when you open the document:

  Doc := Word.Documents.Open('D:\Docs\Word\Test1.doc');
  Doc.Printout;
  Doc.Close;

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

  TeamB don't see posts sent via Google or ISPs
  Use the real Borland server: newsgroups.borland.com
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads