Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DDE Commands to Excel
Message
From
28/10/1999 07:24:52
 
 
To
27/10/1999 00:26:07
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00280742
Message ID:
00282892
Views:
20
Charles,

Here is some code from 2.6 that I used to print a graph in Lotus it may shed some light for you
* Program....: COLCHART.PRG
* Version....: 1.0
* Author.....: John Thornton
* Date.......: February 16, 1995
* Notice.....: Copyright (c) 1995 JET Labs Inc., All Rights Reserved.
* Compiler...: FoxPro 2.5
* Abstract...: Program to print out Collator Performance Chart
* Changes....:

ldfrom = {}
ldto = {}
PRIVATE ALL LIKE l*
tempfile = FULLPATH("collctns.dbf")

* if we ain't in windows blow it off!
IF NOT _WINDOWS
	WAIT WINDOW NOWAIT 'This Selection can only be' + CHR(13) + ;
		'executed from Windows.'
	RETURN 0
ENDIF

IF FILE(tempfile)
	DELETE FILE &tempfile
ENDIF

* pass the from to variables by reference to the datescan screen
= datescan('Print Collator Charts',@ldfrom,@ldto)

* Open the channel to Lotus 123
PRIVATE timecount
= ddesetoption("safety", .F.)
syschannel = DDEINITIATE("123w","system")
IF syschannel = -1
	RUN /n7 C:\123r4w\programs\123w.exe
ENDIF
syschannel = DDEINITIATE("123w","system")
fileopen = DDEEXECUTE(syschannel,'[run({FILE-OPEN "C:\123R4W\NAILS\COLCHART.WK4";;"NO";"AFTER"})]')
channel = DDEINITIATE("123w","colchart")

* Query the data into a temp table
SELECT collprod.date, collprod.machine, ;
	SUM(collprod.quantity) AS ctns,;
	SUM((collprod.quantity * collinv.cntperbox) / collinv.nailsperlb) AS pounds, ;
	SUM(collprod.scrap) AS scrap ;
	FROM collprod, collinv;
	WHERE collinv.prod_code = collprod.prod_code;
	AND collprod.date BETWEEN ldfrom AND ldto;
	GROUP BY collprod.date, collprod.machine ;
	INTO TABLE collctns.dbf

* Put the data into the spreadsheet
SELECT collctns
cell_row = '1'
cell_col = 'b'
CNT = 1
GOTO TOP
datecheck = DATE
month_year = CMONTH(DATE) + ' ' + ALLTRIM(STR(YEAR(DATE)))
= DDEPOKE(channel, "A1", month_year)
DO WHILE NOT EOF()
	cell =  "chart:" + cell_col + cell_row
	day_number = PADL(SUBSTR(DTOC(DATE), 1, 5), 6,"'")
	= DDEPOKE(channel, cell, day_number)
	DO WHILE datecheck = DATE
		cell_row = ALLTRIM(STR(VAL(cell_row) + 1))
		cell =  "chart:" + cell_col + cell_row
		= DDEPOKE(channel, cell, ALLTRIM(STR(ctns)))
		cell_row = ALLTRIM(STR(VAL(cell_row) + 11))
		cell =  "chart:" + cell_col + cell_row
		= DDEPOKE(channel, cell, ALLTRIM(STR(pounds)))
		cell_row = ALLTRIM(STR(VAL(cell_row) + 8))
		cell =  "chart:" + cell_col + cell_row
		= DDEPOKE(channel, cell, ALLTRIM(STR(scrap)))
		SKIP
		cell_row = ALLTRIM(STR(VAL(cell_row) - 19))
	ENDDO
	cell_col = CHR(ASC(cell_col) + 1)  && increment column by one letter
	cell_row = '1' && put us back at row 1
	datecheck = DATE
ENDDO


* Print the chart
= DDEEXECUTE(channel,'[run({EDIT-GOTO "COLLATOR CHART";;"RANGE"})]')
= DDEEXECUTE(channel,'[run({PRINT "SELECTION";1;9999;1;1})]')
WAIT TIMEOUT 5 ''
TIMEOUT = DDEEXECUTE(channel,'[run({EDIT-GOTO "A1";;"RANGE"})]')
IF TIMEOUT = .F.
	timecount = 0
	DO WHILE TIMEOUT = .F.
		WAIT TIMEOUT 1 ''
		TIMEOUT = DDEEXECUTE(channel,'[run({EDIT-GOTO "A1";;"RANGE"})]')
		IF timecount = 30
			EXIT
		ENDIF
		timecount = timecount + 1
	ENDDO
ENDIF

* Delete the data from the spreadsheet
= DDEEXECUTE(channel,'[run({SELECT B1..Z5;B1})]')
= DDEEXECUTE(channel,'[run({EDIT-CLEAR ;"CONTENTS"})]')
= DDEEXECUTE(channel,'[run({SELECT B13..Z16;B13})]')
= DDEEXECUTE(channel,'[run({EDIT-CLEAR ;"CONTENTS"})]')
= DDEEXECUTE(channel,'[run({SELECT B21..Z24;B21})]')
= DDEEXECUTE(channel,'[run({EDIT-CLEAR ;"CONTENTS"})]')
= DDEEXECUTE(channel,'[run({SELECT A1})]')
= DDEEXECUTE(channel,'[run({EDIT-CLEAR ;"CONTENTS"})]')

* Save the file so it don't bitch when we close
= DDEEXECUTE(channel,'[run({FILE-SAVE "C:\123R4W\NAILS\COLCHART.WK4";"1-2-3";;"REPLACE"})]')

* Close the file
= DDEEXECUTE(channel,'[run({FILE-CLOSE})]')
= DDETERMINATE(channel)

* Shut down Lotus 123
syschannel = DDEINITIATE("123w","system")
WAIT TIMEOUT 1 ''
TIMEOUT = DDEEXECUTE(syschannel,'[run({FILE-EXIT})]')
IF TIMEOUT = .F.
	timecount = 0
	DO WHILE TIMEOUT = .F.
		WAIT TIMEOUT 1 ''
		TIMEOUT = DDEEXECUTE(syschannel,'[run({FILE-EXIT})]')
		IF timecount = 30
			EXIT
		ENDIF
		timecount = timecount + 1
	ENDDO
ENDIF

CLOSE ALL

tempfile = FULLPATH("collctns.dbf")

IF FILE(tempfile)
	DELETE FILE &tempfile
ENDIF

*** EOF(colchart.prg) ***
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform