Writing an Excel macro is perhaps the most flexible and efficient way to send data from Excel to the DataHub instance. By using the DDEPoke command in an Excel macro you have complete control over exactly when the data is transmitted. We will also explain how you can write an Excel macro to transmit multiple points at the same time (see Additional Pointers for more details).
In our example, we have chosen to 'add a control button' to run the macro, but you could also run your macro on a timed interval to produce an automatic update on a cycle that you control.
Open a spreadsheet.
From the menu, select , and then .
In the Macro Name: field of the
Macro dialog box, type the name
SendOutput, and press the
button.
In the Visual Basic text entry window that comes up, edit the macro to read as follows:
'
' SendOutput Macro
'
Sub SendOutput()
mychannel = DDEInitiate("datahub", "default")
Application.Worksheets("Sheet1").Activate
Call DDEPoke(mychannel, "my_pointname", Cells(4, 3))
DDETerminate mychannel
End Sub![]() | |
Use the name of your data point from the DataHub instance for
|
![]() | |
We use cell |
Save and close the Visual Basic text entry window.