VTS as Network DDE Client: Using DDE to Enable VTS to Accept Values from an Excel Spreadsheet

When VTS is a network DDE client, data can be entered in the cell of an Excel spreadsheet, and the value will be reported as the value of a tag in VTS.

Configuring VTS as a network DDE client requires a somewhat more complicated process than that of configuring VTS as a DDE server. There are 5 basic steps involved:

1.   Configure a new DDE share object using the DDEShare utility.

2.   Configure a new DDE driver tag within your VTS application to communicate between VTS and the external application with which you wish to share data.

3.   Configure a new output tag within your VTS application to write data to the external application.

4.   Configure a new input tag within your VTS application to read the data that you are writing to the external application to ensure that communications are occurring as they should.

5.   Configure an Excel spreadsheet of the same name specified in your DDE share object, and ensure that the path to the file is correctly configured within Excel for VTS to locate it.

 

These 5 basic steps are described below.

Note: Configuring VTS as a local DDE client is discussed in Using DDE to Enable VTS to Accept Values from an Excel Spreadsheet ".

Part 1: Configure a New DDE Share Object Using DDEShare

In order to designate VTS as a DDE client, you must first configure the network DDE on the server PC using the DDEShare utility. The instructions below will guide you through the correct process of configuring DDEShare.

1.   Open the Windows Start menu.

2.   Select Run from the Start menu. The Run dialog opens similar to the one shown below.

3.   Enter "DDEShare" in the Open edit field.

4.   Click the OK button. The DDE Share on WorkstationName dialog opens.

5.   Double-click the icon that does not display a checkmark. The DDE Shares dialog opens similar to the one shown below.

6.   Click the Add a Share button. The DDE Share Properties dialog opens as shown.

7.   Enter a unique name for the share item in the Share Name field followed by the dollar sign character ($) (e.g. "DDEShare$"). (The Share Name will not accept duplicates any of the names of existing shares in the DDE Shares dialog.)

8.   Enter the application name and topic name in the Old Style and New Style fields as shown below.

9.   Select the Allow start application checkbox. The DDE Share Properties should appear like the one shown below.

Observe the example settings shown in the DDE Share Properties dialog above: "book1.xls" identifies the name of the Excel workbook into which you wish the data from VTS to be entered. This can be substituted for any Excel workbook name you choose; "sheet1" is the name of the Excel sheet that the DDE Share is going to access within the selected Excel workbook. You may enter any sheet name you choose, as long as the sheet exists within the specified Excel workbook; finally, select the "Allow start application" checkbox to enable VTS to start Excel and open to the appropriate sheet in the specified workbook.

 

10. Click the Permissions button. The DDE Share Name Permissions dialog opens as shown, and displays the names of the current users and groups.

11.  Select any local or domain users that you wish to be granted access to the new share, and select an appropriate option from the Type of Access drop-down list. If security is not an issue, you may wish to select "Everyone" and set the Type of Access to "Full Control". This will ensure trouble-free connectivity (as far as new users on the network are concerned). A second option might be to create a new group and grant the group permission to access the new share. You can later enable new users to access the share simply by adding them to the group.

12.  Click the OK button. You are returned to the DDE Share Properties dialog.

13. Click the OK button. You are returned to the DDE Shares dialog where the name of the new share is added to the list.

14. Select the new share in the DDE Shares list. The new share is highlighted.

15. Click the Trust Share button. The Trusted Share Properties dialog opens as shown.

16. Select the Start Application Enable checkbox.

17. Select the Initiate to Application Enable checkbox. The Trusted Share Properties dialog should appear like the one shown below.

18. Click the Set button to set the properties for the new share.

19. Click the OK button. You are returned to the DDE Shares dialog.

20. Click the OK button. You are returned to the DDE Share on WorkstationName dialog.

21. Close the DDE Share on WorkstationName dialog using the Windows close button. You can now begin to configure the DDE driver tag and input/output tags within the VTS application on the client PC.

Part 2: Configure a New DDE Tag to Facilitate Communications between VTS and an External Application

The next step in facilitating communications between VTS (the client) and an external application (such as Microsoft Excel), is to create a new DDE tag.

1.   Run VTS. The VAM opens.

2.   Select the VTS application from which you wish to output data to the external application.

3.   Click the Run button. The application runs.

4.   Log on to the application (if necessary) using your username and password.

5.   Navigate to the page upon which you wish to place your DDE-related tag drawing methods.

6.   Click the Configure button. The configuration toolbox opens.

7.   Click the Tag Browser button. The Tag Browser opens.

8.   Select DDE Driver from the Types drop-down list.

9.   Click the New button. The New DDE Driver Properties folder opens as shown.

10. Enter a name for the new DDE driver tag in the Name field.

11. Enter an appropriate area for the new DDE driver tag in the Area field.

12. Enter an appropriate description for the new DDE driver tag in the Description field. An example of a complete ID tab for a DDE Driver tag properties folder is shown below.

13. Click the Network DDE tab. The properties of the Network DDE tab are displayed as shown below.

14. Enter the name of the server on which the DDE share created in Part 1 was created in the DDE Computer Name field.

15. Enter the name of the new DDE share created in Part 1 (in this example, "DDEShare$"), followed by the extension .OLE. The completed Network DDE tab should appear like the one shown below.

16. Click the OK button. The DDE Driver tag properties folder closes and the information is saved in the tag properties database. You are returned to the Tag Browser where the name of the new DDE tag is displayed and selected.

17. Click the Draw button and select the Comm Indicator drawing method. The Comm Indicator square is attached to the mouse pointer.

18. Click to drop the Comm Indicator object on the page. The Comm Indicator dialog opens as shown.

19. Click the OK button.

The Comm Indicator object enables you to determine the status of communications between the DDE driver and the external application at a glance by changing color. By default, green indicates communications are occurring, red indicates that communications have failed, and gray indicates that the tag is reading invalid (as it currently should be).

The next step is to configure a new analog or digital input tag to read data from the external application.

Part 3: Configure a New Input Tag to Read Data from the External Application

The next step in setting up VTS as a DDE client is to configure a new input tag (either analog or digital) to read data from the external application on the remote PC via the DDE tag created in Part 2. This tag will help you to confirm that the data you will be outputting (via the output tag to be created in Part 4) is being transmitted.

1.   Select Analog Input from the Types drop-down list.

2.   Click the New button. A new analog input tag properties folder opens as shown.

3.   Enter an appropriate name for the new analog input tag in the Name field.

4.   Enter an appropriate area for the analog input tag in the Area field.

5.   Enter an appropriate description for the analog input tag in the Description field. The completed properties for the ID tab of the analog input tag properties folder should appear similar to the example shown below.

6.   Click the I/O tab. The properties of the I/O tab are displayed as shown below.

7.   Select the name of the DDE driver tag from the I/O device drop-down list.

8.   Enter the address of the location from which you wish to read data in the Address field. (In our example, we wish to read data from row 1 cell 1 of the Excel spreadsheet, therefore we will enter "r1c1" in the Address field. The completed I/O tab should appear similar to the one shown below.

9.   Click the OK button. You are returned to the Tag Browser where the new analog input tag is displayed and selected.

10. Click the Draw button. The drawing methods for analog input tags are displayed.

11. Select one of the drawing methods that display the numeric value of the tag (i.e. Numeric Value or Meter1, Meter2, or Meter3). The style dialog associated with the selected drawing method opens.

12. Configure the drawing method's style as you require.

13. Click the OK button. The tag drawing method object is attached to the mouse pointer.

14. Position the drawing object on the page.

15. Click to drop the graphic representation of the analog input tag.

 

The final step in configuring VTS as a DDE client is to add a new output tag to enable the writing of data to the external application on the remote PC. Instructions are provided in the section that follows.

Part 4: Configure a New Output Tag to Write Data to the External Application

The next step in setting up VTS as a DDE client is to configure a new output tag (either analog or digital) to write data to the external application on the remote PC via the DDE tag created in Part 2.

1.   Select Analog Output from the Types drop-down list.

2.   Click the New button. The New Analog Output Properties folder opens.

3.   Enter an appropriate name for the new analog output tag in the Name field.

4.   Enter an appropriate area for the new analog output tag in the Area field.

5.   Enter an appropriate description for the new analog output tag in the Description field. The completed properties of the ID tab of the analog output tag properties folder should appear similar to the example shown below.

6.   Click the I/O tab. The properties of the I/O tab are displayed.

7.   Select the name of the DDE driver tag created in Part 2.

8.   Enter the address of the location to which you wish to write data in the Address field. (In our example, we wish to write data to row 1 cell 1 of the Excel spreadsheet, therefore we will enter "r1c1" in the Address field. The completed I/O tab should appear similar to the one shown below.

9.   Click the OK button. You are returned to the Tag Browser where the new analog output tag is displayed.

10. Click the Draw button. The drawing methods for analog output tags are displayed.

11. Select the Numeric Entry drawing method. The Numeric Entry object is attached to the mouse pointer.

12. Click to drop the graphic representation of the analog output tag. The Numeric Entry style dialog opens.

13. Configure the properties of the Numeric Entry style dialog as you require (see "6: Drawing Tags: Standard Tag Drawing Methods").

14. Click the OK button.

15. Close the Tag Browser.

16. Close the configuration toolbox.

Part 5: Configure an Excel Spreadsheet with the Name as Specified for Your DDE Share Object, and Ensure the Path is Correctly Configured Within Excel

The configuration of VTS as a DDE client is now almost complete. The only tasks remaining are to create a spreadsheet with the same name as was specified for your DDE share object, and ensure that the path is properly configured within Excel so that VTS can locate it.

1.   Run Microsoft Excel.

2.   Create a new spreadsheet. Name this spreadsheet with the exact same name as you configured within your DDE share. For example, consider the DDE Share Properties dialog below. In our example DDE share object, we specified the name of the Excel spreadsheet as "book1.xls". Therefore, our spreadsheet must be named accordingly.

3.   Save the new spreadsheet in your application directory.

4.   Select Tools|Options in Excel's menu. The Options dialog opens.

5.   Click the General tab.

6.   Enter the path to your application directory in the Default File Location field.

7.   Click the OK button.

 

The configuration of VTS as a DDE client is now complete. To output data values to Excel, simply enter a value in the Numeric Entry field (i.e. the drawing method you used for your output tag). When you press the Enter key, the value you entered in the Numeric Entry field for the analog output tag is transmitted to the Excel spreadsheet. If you look in the Excel spreadsheet, the cell you specified to write the data to should display the output number. The drawing method you employed for the analog input tag should also display the number you entered, as it reads it back from the spreadsheet.

Note: If the value you enter in the Excel spreadsheet is not registering, try stopping both Excel and your VTS application, compile your VTS application, then restart it and reenter the value you wish to output.