Hi to all Powercobol users
This is a little example on how invoke MsWord using Powercobol.
<REPOSITORY>
CLASS COM AS "*COM".
<SPECIAL-NAMES>
SYMBOLIC CONSTANT
WDREPLACEALL IS 2
WDREPLACENONE is 0
WDREPLACEONE is 1
WDFINDCONTINUE is 1.
<COMMAND1-Click event>
*>---------- Word Application settings
01 WORD_APPLICATION PIC X(16) VALUE "WORD.APPLICATION".
01 WORD_SERVER OBJECT REFERENCE COM.
01 WORD_DOCUMENT OBJECT REFERENCE COM.
01 WORD_DOCUMENTS OBJECT REFERENCE COM.
01 WORD_FILE PIC X(16) VALUE "..\Letter.doc".
01 OLE-TRUE PIC 1 BIT VALUE B"1".
01 OLE-FALSE PIC 1 BIT VALUE B"0".
01 wdconst pic s9(4) comp-5.
01 wdMatchWholeWord PIC s9(9) comp-5.
01 XNULL PIC S9(9) COMP-5 value 0.
PROCEDURE DIVISION.
SET WORD_DOCUMENT TO NULL
SET WORD_SELECTION TO NULL
SET WORD_DOCUMENTS TO NULL
SET WORD_SERVER TO NULL.
INVOKE COM "CREATE-OBJECT" USING Word_Application RETURNING WORD_SERVER
INVOKE WORD_SERVER "SET-Visible" USING OLE-TRUE
INVOKE WORD_SERVER "GET-Documents" RETURNING WORD_DOCUMENTS
INVOKE WORD_DOCUMENTS "Open" USING WORD_FILE
INVOKE WORD_SERVER "GET-ActiveDocument"
RETURNING WORD_DOCUMENT.
preview-doc.
*> Obtain the doc print preview
INVOKE WORD_DOCUMENT "PrintPreview"
*> Save the file
INVOKE WORD_DOCUMENT "SaveAs"
USING WORD_FILE
*> Send the document to printer
INVOKE WORD_DOCUMENT "PrintOut".
*> Note: You can disable the line below, if you decide
*> to close WinWord.
*> INVOKE WORD_SERVER "Quit".
SET WORD_DOCUMENT TO NULL
SET WORD_SELECTION TO NULL
SET WORD_DOCUMENTS TO NULL
SET WORD_SERVER TO NULL.
There are a lot of methods, properties and events that can be invoked from Powercobol using the MSWord API, supplied in Vb format in the VBAWRD9 help file supplied with the product..You can read this help file to learn better on how can be used other functions.
Hoping this hints help you
This is a little example on how invoke MsWord using Powercobol.
<REPOSITORY>
CLASS COM AS "*COM".
<SPECIAL-NAMES>
SYMBOLIC CONSTANT
WDREPLACEALL IS 2
WDREPLACENONE is 0
WDREPLACEONE is 1
WDFINDCONTINUE is 1.
<COMMAND1-Click event>
*>---------- Word Application settings
01 WORD_APPLICATION PIC X(16) VALUE "WORD.APPLICATION".
01 WORD_SERVER OBJECT REFERENCE COM.
01 WORD_DOCUMENT OBJECT REFERENCE COM.
01 WORD_DOCUMENTS OBJECT REFERENCE COM.
01 WORD_FILE PIC X(16) VALUE "..\Letter.doc".
01 OLE-TRUE PIC 1 BIT VALUE B"1".
01 OLE-FALSE PIC 1 BIT VALUE B"0".
01 wdconst pic s9(4) comp-5.
01 wdMatchWholeWord PIC s9(9) comp-5.
01 XNULL PIC S9(9) COMP-5 value 0.
PROCEDURE DIVISION.
SET WORD_DOCUMENT TO NULL
SET WORD_SELECTION TO NULL
SET WORD_DOCUMENTS TO NULL
SET WORD_SERVER TO NULL.
INVOKE COM "CREATE-OBJECT" USING Word_Application RETURNING WORD_SERVER
INVOKE WORD_SERVER "SET-Visible" USING OLE-TRUE
INVOKE WORD_SERVER "GET-Documents" RETURNING WORD_DOCUMENTS
INVOKE WORD_DOCUMENTS "Open" USING WORD_FILE
INVOKE WORD_SERVER "GET-ActiveDocument"
RETURNING WORD_DOCUMENT.
preview-doc.
*> Obtain the doc print preview
INVOKE WORD_DOCUMENT "PrintPreview"
*> Save the file
INVOKE WORD_DOCUMENT "SaveAs"
USING WORD_FILE
*> Send the document to printer
INVOKE WORD_DOCUMENT "PrintOut".
*> Note: You can disable the line below, if you decide
*> to close WinWord.
*> INVOKE WORD_SERVER "Quit".
SET WORD_DOCUMENT TO NULL
SET WORD_SELECTION TO NULL
SET WORD_DOCUMENTS TO NULL
SET WORD_SERVER TO NULL.
There are a lot of methods, properties and events that can be invoked from Powercobol using the MSWord API, supplied in Vb format in the VBAWRD9 help file supplied with the product..You can read this help file to learn better on how can be used other functions.
Hoping this hints help you