rem ----------------------------------------------------------------------- rem Filename: msword.pls rem Purpose: This example creates a new Word document, inserts some text rem in it and saves its contents into a new file. rem Note: Will not work with Forms 9i and above as it does not rem support OLE automation. rem Date: 12-Sep-2002 rem Author: Sandy (get2sud@yahoo.com) rem ----------------------------------------------------------------------- DECLARE -- Declare the OLE objects MyApplication OLE2.OBJ_TYPE; MyDocuments OLE2.OBJ_TYPE; MyDocument OLE2.OBJ_TYPE; MySelection OLE2.OBJ_TYPE; -- Declare handle to the OLE argument list args OLE2.LIST_TYPE; BEGIN -- Create the Word.Application object and make Word visible -- by setting the 'Visible' property to true MyApplication := OLE2.CREATE_OBJ('Word.Application'); OLE2.SET_PROPERTY(MyApplication, 'Visible', 1); -- get a handle on Documents collection MyDocuments:= OLE2.GET_OBJ_PROPERTY(MyApplication, 'Documents'); -- Add a new document to the Documents collection Mydocument := OLE2.INVOKE_OBJ(MyDocuments, 'Add'); -- Get a handle on Selection object MySelection:=OLE2.GET_OBJ_PROPERTY(MyApplication, 'Selection'); -- Insert the text 'Hello Word97!' into word document OLE2.SET_PROPERTY(MySelection, 'Text', 'Hello Word97!'); -- Save the document to the filesystem as EXAMPLE.DOC args := OLE2.CREATE_ARGLIST; OLE2.ADD_ARG(args, 'C:\DOCS\EXAMPLE.DOC'); OLE2.INVOKE(MyDocument, 'SaveAs', args); OLE2.DESTROY_ARGLIST(args); -- Close the document OLE2.INVOKE(MyDocument, 'Close'); -- Release the OLE objects OLE2.RELEASE_OBJ(MySelection); OLE2.RELEASE_OBJ(MyDocument); OLE2.RELEASE_OBJ(MyDocuments); OLE2.RELEASE_OBJ(MyApplication); END;