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") endifWhen I run it, I get :3139 DDEInitiate: Bad Channel NumberHelp!! 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 macroMore...
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: W14140Filename: 3139 DDEInitiate-Bad Channel Number.txt