4.1. Getting Data into
Before starting, to see any results you
will have to ensure that you have some kind of data being fed
into the Cascade DataHub. If your system isn't set up for this yet, you
can create a local data feed by following the steps outlined
in Section 1.2, “Test with simulated data”.
There are two ways to get data into Excel from
the Cascade DataHub: by setting up a DDEAdvise loop
to receive data automatically, or by using a
DDERequest command from a macro to read data. Deciding which to
use depends on your situation. We suggest you become familiar
with both. For more information about DDE and these commands,
please refer to Section 2.3.1, “DDE Protocol” and
Appendix G, DDE Overview.
4.1.1. Method 1 - Drag and
Drop using DDEAdvise
easiest way to get data into Excel is to drag and drop point
names from the DataHub Data Browser directly into the Excel
spreadsheet. This automatically sets up a
DDEAdvise loop between Excel and
the DataHub. DDEAdvise loops update
automatically so you will always see the latest data in your
- Right click on the Cascade DataHub system-tray icon and choose
In the Properties window,
- Ensure that the box Act as a DDE
server is checked, and that the name
datahub appears in the
DDE Service Name area. If not,
click the button and add
the name datahub.
- Click to close the
Right click on the Cascade DataHub system-tray icon and choose
from the pop-up
menu to open the Data Browser.
- Ensure that the Drag & Drop Style
at the bottom of the Data Browser is set to
- Open an Excel worksheet.
In the Data Browser, click on the label for a point
and drag it into the Excel worksheet.
You should see the data update in the
worksheet at the same rate it is updating in
the Cascade DataHub.
You can select multiple points for drag and drop
by using Shift-click or
If your data displays but does not update, you might
need to change your settings in Excel. Please refer to
Chapter 15, Troubleshooting for more
When you save and close a spreadsheet
connected to the Cascade DataHub, and then attempt to reopen it, you
may get one or more messages, depending on your security
settings in Excel, or other circumstances. Here's a summary
of each message, and what to do:
- This document contains macros. Enable them?
- This workbook contains links. Update them?
Click . If
the DataHub is already running, all the links
should then update automatically. If the DataHub
is not running, you will get a
#REF! entry in each cell that
has an advise loop established with the DataHub,
and the next message (see below) will probably
- Remote data not accessible. Start DataHub?
Click . At this
point the best thing to do is close the
worksheet, start the DataHub manually, and then
reopen the worksheet. When you update the
spreadsheet (see above) this time you won't get
any #REF! entries. If,
instead of you click
at this point,
the DataHub will not start, but instead generate
an error message, and Excel may even crash later
4.1.2. Method 2 - Excel Macros using
may prefer to manually read data into your spreadsheet,
rather than use a DDEAdvise loop to
constantly accept new values. It may be that you intend to
print reports only a couple of times a day and don't need to
see every point change in between. You can have Excel read
specific data points from the Cascade DataHub at your request by
triggering the DDERequest command from
within a macro.
DDERequest within a macro gives you
complete control over when Excel reads new point values, and
lets you read several data points at one time. To run the
macro, it is convenient to link it to a control button.
This is explained in Add a Control
- Open a spreadsheet.
- From the menu, select
, and then
- In the Macro Name: field of the
Macro dialog box, type the name
GetInput, and press the
In the Visual Basic text entry window that comes up,
edit the macro to read as follows:
' GetInput Macro
mychannel = DDEInitiate("datahub", "default")
newval = DDERequest(mychannel, "my_pointname")
Sheet1.Cells(2, 3) = newval
Use the name of your data point
from the Cascade DataHub for
We use cell
C2 in this example. If you need to use
another cell, you will have to replace (2,
3) with the row and column numbers of the cell
you wish to use.
- Save and close the Visual Basic text entry
220.127.116.11. Add a Control Button
Activate the Forms toolbar by clicking on the
menu and selecting
, and then
- Click on the button icon, and then click in cell
D2. (We use this cell in our example,
but you can choose another cell if you'd like.) An
Assign Macro window should
Change the label on the button to
- 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 .
- Save the spreadsheet.
18.104.22.168. Receive the data
- Now you're ready to receive the data. Open the
DataHub Data Browser if it is not already open, go to the
default data domain, and find the name of the
- Click on the point to highlight it. The point
name should appear in the Selected
Point: field at the top of the Data
Type a new value for the point into the
Enter new value: field and press
- Go to Excel and click the
button. You should see the
data update each time you click the button.