Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call Winword from Powercobol 6

Status
Not open for further replies.

Tromba

Programmer
Apr 7, 2001
85
0
0
IT
Hi to all Powercobol users

This is a little example on how invoke MsWord using Powercobol.

<REPOSITORY>
CLASS COM AS &quot;*COM&quot;.

<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 &quot;WORD.APPLICATION&quot;.
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 &quot;..\Letter.doc&quot;.

01 OLE-TRUE PIC 1 BIT VALUE B&quot;1&quot;.
01 OLE-FALSE PIC 1 BIT VALUE B&quot;0&quot;.
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 &quot;CREATE-OBJECT&quot; USING Word_Application RETURNING WORD_SERVER

INVOKE WORD_SERVER &quot;SET-Visible&quot; USING OLE-TRUE

INVOKE WORD_SERVER &quot;GET-Documents&quot; RETURNING WORD_DOCUMENTS
INVOKE WORD_DOCUMENTS &quot;Open&quot; USING WORD_FILE

INVOKE WORD_SERVER &quot;GET-ActiveDocument&quot;
RETURNING WORD_DOCUMENT.

preview-doc.
*> Obtain the doc print preview
INVOKE WORD_DOCUMENT &quot;PrintPreview&quot;
*> Save the file
INVOKE WORD_DOCUMENT &quot;SaveAs&quot;
USING WORD_FILE
*> Send the document to printer
INVOKE WORD_DOCUMENT &quot;PrintOut&quot;.

*> Note: You can disable the line below, if you decide
*> to close WinWord.
*> INVOKE WORD_SERVER &quot;Quit&quot;.

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

 
Finally I have find a site for the cobol-language, I wish a long life !!!!
 
Hi Tromba,
do you have and example of how to change fonts and other methods?
Based in your example i can send a line of text to word, but i don't know how to change the look of the report.

thanks in advance

Jose
 
The example in this forum and PowWord are very usefull. My question is : do they work only in PowerCobol 6.1 ?
I'v got both Powercobol 6.1 and 5.0 but I still use 5.0 because my customers have this runtime installed.
 
Hi Crobby

Yes, PowWord works also with v5.0.
There is only a little change to made on the REPOSITORY SECTION:
You must change the CLASS COM AS &quot;*COM&quot; with CLASS OLE AS &quot;*OLE&quot;.
This modification is needed for a compatibility with Powercobol v5.0. The class COM was introduced with v.6.1.

Hope in this help.

Gianni
alias Tromba
softline2000@tin.it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top