Sending a network variable update using excel – Echelon LNS DDE Server User Manual

Page 82

Advertising
background image

timer expires, this property remains at 0 until explicitly reset to another value.

Setting this property prevents a separate network variable update being sent on the
network for each field updated. Set this property to a value such that all fields will

be changed before the update is sent.

Sending a Network Variable Update Using Excel

Three separate functions are required to send a network variable update using Excel.
They are the Excel DDEInitiate(), DDEPoke(), and DDETerminate() functions. To

call these functions, you must implement a Visual Basic for Applications (VBA)

macro for each value to be requested.

The update macro will typically be called from an ActiveX control such as a button.

To update a network variable update using an Excel button control, follow these
steps:


1. Open an Excel spreadsheet and select the worksheet that will contain the button.

2. If the Control Toolbox is not displayed, point to Toolbars on the View menu, and

then select Control Toolbox.

3. Click the Command Button control on the Control Toolbox.

4. On the worksheet, drag the control to the size you want.

5. To set the properties for the control, right-click the control, and then select

Properties on the shortcut menu.

6. To add VBA macro code to the control, right-click the control, and then select

View Code on the shortcut menu. The VBA editor will be opened, and a new VBA
function will be created for your button code.

7. Enter the following code:

Dim Channel As Long

Channel = DDEInitiate(Application, Topic)

DDEPoke Channel, Item, Value

DDETerminate (Channel)

Following is a description of the parameters:


Application

The DDE application as a string. By default, this is
“LNSDDE” for the LNS DDE Server.

Channel

A DDE channel number created by the DDEInitiate()
function, as a long.

Item

A DDE item as a string, as described in Specifying a Network
Variable
earlier in this chapter.

Topic

A DDE topic as a string. For network variables, this will be
an LMNV, DevNV, or NV topic as described in Topics in
Chapter 4 and in Specifying a Network Variable earlier in this

chapter.

5-12

Reading and Writing Network Variables

Advertising