Passing Data Across a Network Using Network DDE
One of the more interesting features of Windows for
Workgroups and Windows 95/98 is that they both support a feature
called "Network DDE". Network DDE allows DDE data to be
passed across a network from one PC to another. This means that
it is possible to have the WinWedge (or any other DDE enabled application)
running on one or more PCs providing real time data to an application
running on an entirely different PC in the network. Note: Network
DDE must be enabled in Windows 95/98 by running the program NETDDE.EXE.
You may want to place the NETDDE program in your StartUp folder
so that it runs automatically when you start Windows 95/98.
The process of setting up a network DDE
connection is fairly simple and involves using the ClipBook application found in the MAIN
program group in Windows. The ClipBook extends the concept of the Windows Clipboard across
a network. The ClipBook allows you to create "ClipBook Pages" that can be
"Shared" with other computers on a network. Once you create and share a page on
one computer, other computers on the network can "connect" to that page. If the
page contains data from a DDE server (like the Wedge), then you can set up DDE links to
the data and the data will be passed to any client application on the network just as if
the client were running in the same local PC as the server application.
Suppose you have the Wedge running in one PC
and you want to link data from "Field(1)" in the Wedge to a cell in an Excel
spreadsheet running in another PC on your network. The following steps outline the
procedure:
Note: All versions
of Excel prior to 5.0c have a bug that causes Network DDE connections to fail. If you have
an earlier copy of Excel you can get an update from Microsoft for free if you call their
technical support department.
1. Load and activate the Wedge on the first
PC. When the Wedge window appears, place the cursor in input data field
"Field(1)" and select "Copy" from the EDIT menu.
2. Open the ClipBook program in the PC where
the Wedge is running and select "Local ClipBook" from the WINDOW menu and then
select "Paste" from the EDIT menu. In the dialog box that appears, type MyPage
in the text box labeled "Page Name" and make sure that the check box labeled
"Share Item Now" is checked.
3. Open up the ClipBook program on the second
PC where Excel will be run and select "Connect..." from the FILE menu. When the
dialog box appears, enter the network name of the PC where the Wedge is running and click
the OK button. (If you do not know the name of the computer, click the "Browse"
button and the ClipBook will display a list of all computers in the Network). This will
display a new window that will contain all the "shared" items in the ClipBook
running on the other PC. You should see an item in the window with the name
"MyPage" and then select "Copy" from the EDIT menu. This operation
takes the data from the ClipBook on the other PC and places it in the local clipboard.
4. Open Excel and place the cursor in the cell that you
want to link the data to and select "Paste Special" from Excel's EDIT menu. In
the dialog box that appears, check the option labeled "Paste Link" and then
click the OK button. If the link is successful, you will see the data from Field(1) in the
cell and you will also see the formula for the link in the formula bar. Whenever new data
is received by the Wedge it will be updated in the spreadsheet cell.
If you look at the formula
that Excel returns from the above Copy / Paste Link procedure, it will look something like
the following:
=\\ComputerName\NDDE$|$MyPage.dde!Field(1)
The formula for a DDE link in
Excel is expressed using the DDE Application Name followed by a pipe character (|), a DDE
Topic followed by an exclamation mark and then the DDE Item Name.
If you were to use the Copy / Paste Link
method of establishing a DDE link between the Wedge and Excel where both programs were
running on the same PC, the linked cell in Excel would contain a formula similar to the
following:
=WinWedge|COM1!Field(1)
The difference between a local
DDE connection and a network DDE connection is that instead of using the DDE Server's
executable file name, the Network DDE Application Name becomes two slashes followed by the
name of the computer running the DDE Server program followed by a single slash and the
word: NDDE$. The DDE Topic also changes to a dollar sign followed by the "Page
Name" that was assigned in the ClipBook application followed by a period and the word
DDE. The DDE Item Name stays the same.
After you create a "Page Name" using
the ClipBook application and paste data from a DDE server into the page, the page name and
the DDE connection data contained in it will continue to exist even after you close the
ClipBook application on both computers. You can even shut down Windows on both computers
and when you restart you will be able to re-establish the DDE links using the same Network
DDE Application, Topic and Item Names.
In other words, after you set up a Network DDE
connection once, you do not need to go through the same procedure in the ClipBook every
time you want to re-establish the link.
If you wanted to send a DDE command from Excel
to a copy of the Wedge running on a remote PC, all you need to do is to change the DDE
Application Name and DDE Topic to the new Network DDE Application and Topic Names. For
example the following Excel macro could be used to send the "BEEP" command to a
Wedge on a remote PC. (We will assume that the name of the remote PC is "Bob"
and that a ClipBook page was created on that PC using the name "MyPage" and that
the page contains a DDE data field from the Wedge.)
Sub BeepRemoteWedge()
chan =
DDEInitiate("\\BOB\NDDE$", "$MyPage.DDE")
DDEExecute chan, "[BEEP]"
DDETerminate chan
End Sub
|