WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DDE

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

3139 DDEInitiate: Bad Channel Number

Keywords: 	  3139 DDEInitiate: Bad Channel Number 

Question:

I am trying execute a VBA macro with a this WIL program.
DDEChan = DDEInitiate("Excel", "System")
; If DDECHAN is OK, Execute DDE
If DDECHAN == 0
result=DDEExecute(1,'[Run("i:\CICS\CICS_Stats|Personal.xls")]')	 ;this runs an Excel macro
; Close DDE
DDETerminate(1)
If result == @FALSE
Message("DDE Execute", "Failed")
else
Message("DDE Execute", "Operation Complete")
endif
else
Message("DDE operation unsuccessrful", "Check your syntax")
endif
When I run it, I get :
3139 DDEInitiate: Bad Channel Number
Help!! What's going on? Am I wrong in thinking that it would dynamically locate the right channel number? If I am wrong, where do I find the right channel number?

Answer:

New code....

DDEChan in resutend by the DdeInitiate command. If it is zero it is NOT OK.

Then DDEExecute needs the channel number like...

	DDEChan = DDEInitiate("Excel", "System")
	; If DDECHAN is OK, Execute DDE
	If DDECHAN != 0
	result=DDEExecute(DDEChan,'[Run("i:\CICS\CICS_Stats\Personal.xls")]')  ;this runs an Excel macro

More...

This DDE example runs the Microsoft Excel macro named "Macro1" in Personal.xls.
DDEChan = DDEInitiate("Excel", "System")


; If DDECHAN is OK, Execute DDE

If DDECHAN != 0

   result=DDEExecute(DDEChan,'[Run("Personal.xls!Macro1")]')  ;this runs an Excel macro

endif


DDETerminate(DDEChan)

This OLE example runs an Excel macro.

; Start excel here
excelxls = objectopen("Excel.Application")
excelxls.visible = @true

rptxls = excelxls.workbooks
rptxls.open ("c:\data\excel\TPM Reporting for CSD.xls")

; run the excel macro here the
; macro name is "gina_resolution report and the rname is the parameter passed to it.

excelxls.run("gina_resolution_report", rname)

; close up
excelxls.quit
objectclose(excelxls)

You will need to see that product specific documentation....


Article ID:   W14140
Filename:   3139 DDEInitiate-Bad Channel Number.txt
File Created: 2000:08:30:13:48:52
Last Updated: 2000:08:30:13:48:52