Forms4.5, ole2 and word
Date: Fri, 30 Apr 1999 11:23:51 GMT
Message-ID: <7gc3s5$g5v$1_at_nnrp1.dejanews.com>
Hi,
I have to manipulate word documents from Forms4.5 using ole2. I have read with interest the code posted by czclarke on the 30th of March (see below). As I am a beginner, I have a few questions :
I have to pass parameters for several methods (from VisualBasic) like 'Open',
'Add', 'InsertFile', 'SaveAs', ... .
In the example below (for the 'Print' action), parameters seems to be passed through the arglist. But : - How the program knows which parameters are concerned, as they are seems to be specified in comments (in the arglist I only see the values for these parameters)? - Anyway, I have tried this code for the 'SaveAs' method :
With just one argument, it works
arglist := ole2.CREATE_ARGLIST;
ole2.ADD_ARG(arglist, 'C:\Kasia\Tests\truc.doc'); ole2.INVOKE(document,'SaveAs',arglist); ole2.DESTROY_ARGLIST(arglist);
With more than one argument it doesn't work :-(
arglist := ole2.CREATE_ARGLIST;
ole2.ADD_ARG(arglist, 'C:\Kasia\Tests\truc.doc'); ole2.ADD_ARG(arglist, 'wdFormatDocument'); ole2.INVOKE(document,'SaveAs',arglist); ole2.DESTROY_ARGLIST(arglist);
So, how to do that?
Thanks for your help.
Kasia
p.s. Sorry for my (bad) english.
PROCEDURE comms_concepts IS
BEGIN
DECLARE
ole_application ole2.obj_type; ole_document ole2.obj_type; ole_args ole2.list_type;
BEGIN
- Create the Word.Application and make it visible ole_application:= ole2.create_obj('Word.Application'); ole2.set_property(ole_application,'Visible',1);
- Get a handle on the documents collection ole_document := ole2.get_obj_property(ole_application, 'Documents');
- What word file to open ole_args:= ole2.create_arglist;
ole2.add_arg(ole_args, 'e:\temp\test1.doc');
- Open Word document specified in the argument list ole_document := ole2.invoke_obj(ole_document, 'Open', ole_args); ole2.destroy_arglist(ole_args);
--Print the Word document, nb. all arguements optional
ole_args:= ole2.create_arglist; ole2.add_arg(ole_args,'wdPrintAllDocument'); --Range --
'True'); --Background ole2.add_arg(ole_args,
'False'); --Append ole2.add_arg(ole_args,
wdPrintAllDocument,wdPrintCurrentPage,wdPrintFromTo,wdPrintRangeOfPages,wdPri
ntS election ole2.add_arg(ole_args, 'False'); --OutputFileName ole2.add_arg(ole_args, 'null'); --From ole2.add_arg(ole_args, 'null'); --To ole2.add_arg(ole_args, 'wdPrintDocumentContent'); --Item -- wdPrintAutoTextEntries,wdPrintComments,wdPrintDocumentContent,wdPrintKeyAssig nme nts,wdPrintProperties,wdPrintStyles. ole2.add_arg(ole_args,
'1'); --Copies ole2.add_arg(ole_args, 'null');
--Pages ole2.add_arg(ole_args, 'wdPrintAllPages'); --PageType -- wdPrintAllPages,wdPrintEvenPagesOnly,wdPrintOddPagesOnly ole2.add_arg(ole_args, 'False'); --PrintToFile ole2.add_arg(ole_args, 'True'); --Collate ole2.add_arg(ole_args, 'null'); --FileName ole2.add_arg(ole_args, 'null'); -- ActivePrinterMacGX ole2.add_arg(ole_args, 'null'); -- ManualDuplexPrint --ole2.invoke(ole_application, 'PrintOut'); ole2.invoke(ole_application, 'PrintOut', ole_args); ole2.destroy_arglist(ole_args);
--Release the OLE objects
ole2.release_obj(ole_application);
ole2.release_obj(ole_document);
END; -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri Apr 30 1999 - 13:23:51 CEST