Setting up an Excel DDE Poke Example

<< Click to Display Table of Contents >>

Navigation:  Instrument Connectivity > DDE (Dynamic Data Exchange) - Overview >

Setting up an Excel DDE Poke Example

Previous pageReturn to chapter overviewNext page

 

This example is for Excel 2000:

 

This is a simple example that sends the contents of Cell A1 on Sheet1 to the SpecView User variable called SpecView.Number1

 

1.        Open a new Sheet inside Excel

2.        Show the Forms Toolbar

3.        Choose the Button tool from the Forms Toolbar

4.        Draw out a button on the sheet

5.        When the Assign Macro box appears, click New

6.        Type (or paste) the following lines of code in between the 2 lines, for example:

                     Sub Button1_Click()

 

End Sub

 

channelNumber = Application.DDEInitiate(app:='SpecView', topic:='var')

Set rangeToPoke = Worksheets('Sheet1').Range('A1')

Application.DDEPoke channelNumber, 'SpecView.Number1', rangeToPoke

Application.DDETerminate channelNumber

 

7.        Save and close Microsoft Visual Basic

8.        Click on the button with MB2, choose Edit Text to modify the button's label.

9.        Set A1 to, for example 20.5

10.        Click your button to do the Poke.

 

 

For a slightly more complex example which allows the name of the variable as well as the value to be defined by a Cell, follow points 1 to 5 above, then:

 

6.Type (or paste) in the example code from the previous help section in between the 2 lines, for example:

Sub Button1_Click()

 

End Sub

7.        Save and close Microsoft Visual Basic

8.        Click on the button with MB2, choose Edit Text to modify the button's label.

9.        Then set the cells to, for example, as follows:

Set B3 to: SpecView

Set C3 to: var

Set D3 to the variable to be set, for example: 'Zone1.Setpoint

Set E3 to, for example: '20.5

10.        Click your button to do the Poke.

 

 

This example is for Excel 97:

1.        Open a new Sheet inside Excel

2.        Show the Drawing Toolbar

3.        Choose the Button tool from the Drawing Toolbar

4.        Draw out a button on the sheet

5.        When the Assign Macro box appears, choose New Macro

6.        Type in the example code from the previous help section

7.        Save the Macro

8.        Then set the cells to, for example, as follows:

Set B3 to: SpecView

Set C3 to: var

Set D3 to the variable to be set, for example: 'Zone1.Setpoint

Set E3 to, for example: '20.5

9.        Click your button to do the Poke.

Return to DDE help topics