Sending data from Excel to the data server requires a macro. Once a macro has been created and assigned to a button, sending the data is just a matter of clicking the button and seeing the data arrive on the data server.
![]() | The finished spreadsheet is included in testfnl.xls in the Cascade Connect distribution. You can save it as test.xls if you want to use it without going through the steps to create it. |
Open the test.xls spreadsheet you created in the previous part of the tutorial.
From the Tools menu, select Macro, and then Macros....
In the Macro Name: field of the Macro dialog box, type the name SendOutput, and press the Create button.
In the Visual Basic text entry window that comes up, edit the macro to read as follows:
'
' SendOutput Macro
'
Sub SendOutput()
mychannel = DDEInitiate("cascade", "data")
Application.Worksheets("Sheet1").Activate
Call DDEPoke(mychannel, "output1", Cells(4, 3))
DDETerminate mychannel
End SubSave and close the Visual Basic text entry window.
Follow these steps in test.xls:
Type the text Output => into cell B4 and right justify it.
Change the name of cell C4 to output1.
Activate the Forms toolbar by clicking on the View menu and selecting Toolbars, and then Forms.

Click on the button icon, and then click in cell D4. An Assign Macro window should appear.
Select SendOutput and click OK.
Change the label on the button to "Send".

For appearance, you can move the button, resize it with the handles, and change the size of the text by right-clicking on it and selecting Format Control.
Save test.xls and exit.
To see the data arrive on the data server, you will need to start the cascwait program there. That program acts as the data server client and displays messages it receives to the standard output.
Using a console on the data server or a telnet session from Windows, type the following command at the command prompt:
[sh]$ cascwait
Now you're ready to send the data. In Windows, double click on the Excel Test icon you have created.
Type a number (for example 24) in cell C4 and press Enter.
Click the Send button.
On the data server you should see the following message:
Received message: (point output1 2 24)
This indicates that Excel data is being sent to the data server.