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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tromba - please

Status
Not open for further replies.

josuecaleb

Programmer
Jun 30, 2003
1
BR
In your program a little example on how invoke MsWord using Powercobol. I need :

COPY, PASTE, SELECT

THANK

Josue - Brasil.
 
If all you are looking for is a routine to allow you to copy and paste to the clipboard from cobol, the following routine I developed should be helpful.

This solution requires the following libraries to be included from Microsoft Platform SDK. If you have any of Microsoft Visual programming tools, you may already have these libraries.

WINSPOOL.LIB
GDI32.LIB
USER32.LIB
ADBAPI32.LIB
F3BICBLR.LIB <- From Fujitsu

Here is the code:

@OPTIONS ALPHAL(WORD)
IDENTIFICATION DIVISION.
PROGRAM-ID. BWCLIPBD.
ENVIRONMENT DIVISION.
DATA DIVISION.
BASED-STORAGE SECTION.
01 GLOBALDATA PIC X BASED ON GLOBALPTR.
01 GLOBALINPUT PIC X(8000) BASED ON INPUT-PTR.
WORKING-STORAGE SECTION.
78 GMEM-GLOBAL value 8194.
01 long typedef pic s9(9) comp-5.
01 ENV-NAME PIC X(40).
01 GLOBALPTR POINTER.
01 INPUT-PTR POINTER.
01 GLOBAL-MEM type long.
01 GLOBAL-HANDLE type long.
01 GLOBAL-LEN type long.
01 MEM-FLAGS type long VALUE GMEM-GLOBAL.
LINKAGE SECTION.
01 IO-FUNCTION PIC X.
01 IO-AREA PIC X.
01 IO-LENGTH PIC S9(9) COMP-5.

PROCEDURE DIVISION USING IO-FUNCTION
IO-AREA
IO-LENGTH.
BEGIN SECTION.
IF IO-FUNCTION NOT = 'I' AND NOT = 'R'
MOVE 'X' TO IO-FUNCTION
GOBACK.
IF IO-FUNCTION = 'R'
PERFORM RETRIEVE-TEXT
ELSE
PERFORM INSERT-TEXT
END-IF.
GOBACK.

INSERT-TEXT SECTION.
COMPUTE GLOBAL-LEN = IO-LENGTH + 1.
INITIALIZE GLOBAL-MEM.
CALL &quot;OpenClipboard&quot; WITH STDCALL LINKAGE
USING BY VALUE 0.
IF RETURN-CODE NOT = ZERO
CALL &quot;EmptyClipboard&quot; WITH STDCALL LINKAGE
CALL &quot;GlobalAlloc&quot; WITH STDCALL LINKAGE
USING BY VALUE MEM-FLAGS, GLOBAL-LEN
RETURNING GLOBAL-MEM
IF GLOBAL-MEM = ZERO
MOVE '1' TO IO-FUNCTION
CALL &quot;CloseClipboard&quot; WITH STDCALL LINKAGE
GOBACK
END-IF
CALL &quot;GlobalLock&quot; WITH STDCALL LINKAGE
USING BY VALUE GLOBAL-MEM
RETURNING GLOBALPTR
MOVE IO-AREA (1:IO-LENGTH) TO GLOBALDATA (1:IO-LENGTH)
MOVE X'00' TO GLOBALDATA (GLOBAL-LEN:1)
CALL &quot;GlobalUnlock&quot; WITH STDCALL LINKAGE
USING BY VALUE GLOBAL-MEM
CALL &quot;SetClipboardData&quot; WITH STDCALL LINKAGE
USING BY VALUE 1 GLOBAL-MEM
CALL &quot;CloseClipboard&quot; WITH STDCALL LINKAGE
END-IF.
MOVE SPACES TO IO-FUNCTION.
INSERT-TEXT-EXIT.
EXIT.

RETRIEVE-TEXT SECTION.
CALL &quot;OpenClipboard&quot; WITH STDCALL LINKAGE
USING BY VALUE 0.
IF RETURN-CODE NOT = ZERO
CALL &quot;GetClipboardData&quot; WITH STDCALL LINKAGE
USING BY VALUE 1
RETURNING GLOBAL-HANDLE
CALL &quot;GlobalLock&quot; WITH STDCALL LINKAGE
USING BY VALUE GLOBAL-HANDLE
RETURNING INPUT-PTR
UNSTRING GLOBALINPUT
DELIMITED BY X'00'
INTO IO-AREA (1:IO-LENGTH)
CALL &quot;GlobalUnlock&quot; WITH STDCALL LINKAGE
USING BY VALUE GLOBAL-HANDLE
CALL &quot;CloseClipboard&quot; WITH STDCALL LINKAGE
ELSE
MOVE SPACES TO IO-AREA (1:IO-LENGTH)
END-IF.
RETRIEVE-TEXT-EXIT.
EXIT.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top