Hi all,
My application registers with Windows as a DDE Server, and communicates with several different 3rd party apps through DDE. We're just now exploring how to communicate via Excel by the same means.
In Excel, I put a button on the worksheet to request information from my app. This works fine. Excel requests the current row number, and the correct response is received by Excel. I can also request the row count, and the correct response is received by Excel.
I put another button on the worksheet to wrte information to my app. This doesn't work. In fact, the remotesend event in my app isn't even triggered. (I put MessageBox's in the remotesend, remoterequest and remoteexec event for testing purposed.) The code I'm using is Excel is :
Sub Button5_Click()
Dim channelNumber As Long
Dim dataToSend As String
Dim dataSendTo As String
dataSendTo = "3~tAsFound"
dataDataToSend = "Poke"
channelNumber = Application.DDEInitiate(app:="CMI Datasheet", topic:="1000453600")
Application.DDEPoke channelNumber, dataSendTo, dataDataToSend
Application.DDETerminate channelNumber
End Sub
I tried enclosing the DDEPoke command with (...) For some reason, Excel doesn't like it! The documentation I found on DDEPoke doesn't have () either.
I'm just wondering why remotesend event doesn't even get triggered. Any thoughts, advice would be appreciated.
~~~Tracy
I tried eliminating the declaration of dataSendTo and just using the SET statement as I do with cellToPoke. This causes an error, probably because dataSendTo is a concatonation of 2 cells with a tab character between each value. I changed the Declaration from String to Variant. This does work, just as setting the declartion to String works so defining it as String or Variant doesn't seem matter. Either way I still have to include the line that says "dataSendTo = ... " .
The "topic:=" parameter is in the DDEInitiate command, not the DDEPoke command. I changed it because the topic was originally hardcoded, and I wanted it to come from a cell on the spreadsheet.