DASYLab Techniques
DASYLab DDE Examples

Introduction
Working with DASYLab DDE functions requires some knowledge of how DDE (dynamic data exchange)
works. This obsolete Windows function allows DASYLab to send and receive data to an external
program, and to send and receive commands from an external program.
Microsoft has advised that the DDE technology is obsolete and should not be used. They recommendthat programmers move to the Microsoft Automation (OLE) model. DASYLab 2020 supports theActiveX/OLE automation model in the Script module. Several Excel examples have been published forthe Script module using that communications technique.
However, many DASYLab users prefer to continue to use the DDE functions as they are simple andstraightforward. This technical note describes several examples for using the DDE functions withDASYLab 2020. Most of these techniques will work with earlier versions, but the examples were createdwith 2020 and will work with future versions of DASYLab until Microsoft completely removes DDE fromthe operating system.
The examples that are described in this technical note are:Write to Excel at 1 samples/second
Read from Excel sheet at high speed
Write to Excel sheet at high speed
Send Commands to Excel
Send Global Strings and Variables to Excel
Start Excel with a filename
All of the examples require Microsoft Excel 2003 or later. They were created and tested withDASYLab 2020 and Excel 1903 32-bit on a Windows 10 64-bit operating system.
For most of the examples the Excel program must be open prior to operating and configuring theexamples. Some examples include the Excel sheet. Read the description of the example, open it, and try
it. Try making changes to see how the different settings work. When the example uses Global strings orvariables, look in the Options menu, Global variables and strings to see the settings, including theAdvanced settings.
There is no one location for Excel commands, but the Microsoft support site has an article on starting
Excel from a command line. Other references are from the Excel VBA programming references.
These examples are based on the DASYLab DDE functions. Prior to using them, review the DASYLab Helpand these articles in the Measurement Computing Knowledge Base, kb.mccdaq.com.

DASYLab Techniques - DASYLab DDE Examples

Page 2 of 13

DDE in DASYLab writing to Excel
Transferring Text from DASYLab to Microsoft Excel
Using DASYLab to Read Data from Microsoft Excel

The DASYLab Help includes both the help for the DDE functions and the DDE Input and Output modules.
There is a complete example shown in the Procedures section of the Help.

DASYLab Techniques - DASYLab DDE Examples
The DDE module help provides some overview information, as well as module specific help.

Page 3 of 13

DASYLab Techniques - DASYLab DDE Examples

Page 4 of 13

ExamplesThe following examples can be found at
ftp://ftp.mccdaq.com/downloads/example_programs/DASYLab_App_and_App_Notes/

Write to Excel at 1 samples/second
DASYLab 2020 Write to DDE 1s-second.dsb
This worksheet is the straightforward example for writing to Excel. It stores two columns of data, row byrow. Column 1 ("A") is the time, and Column 2 ("B") is the data value. Each DDE Output module canwrite up to 16 columns. Use more than one module for additional channels.

To set this up, create the Input/Output -> DDE -> DDE Output module.
Configure the module to use Excel as the Server. Do this by clicking on the Server Button.

DASYLab Techniques - DASYLab DDE Examples

Page 5 of 13

In the Browse DDE Server dialog, select Excel (it must be open), and then select the sheet. I have chosen
to use a new workbook with the default names.

Next, select Generated for the definition field. This setting allows you to create a variable item name.

Click on the Item... button. To save two columns of data, row by row, enter the following
Text part A: RCounter 1: Start value 1, Increment by 1, Increment after 1, no restart.

DASYLab Techniques - DASYLab DDE Examples

Page 6 of 13

Text part B: C1:C2

These settings will create a valid Excel cell location, R1C1:C2, which would look like A1:B1 in normal
Excel notation. DASYLab cannot easily iterate on the A1:B1 notation, but can easily iterate on theRow/column notation, R1C1.
To include time, click Ok to close the Item properties, and click on the Format... button on the main DDE
Output properties dialog box.
Check the Time channel setting to selectReal time. This will put the current clocktime into the first column. If you onlywant the Measurement time, select thatto store the number of seconds since
the start of measurement.

DASYLab Techniques - DASYLab DDE Examples

Page 7 of 13

Click OK to close both dialog boxes. Make sure that the worksheet is wired, and that the sample rate isslow (1 sample/second). Start the measurement, and observe the data being stored.
Note that the time value stored in the Excel sheet is a number, not a date or time. You will need toformat the entire column to use a date/time format. The value does include the date, so you will needto use a custom Excel format to show both date and time with seconds. The format mm/dd/yyyy
hh:mm:ss will yield a complete date - 01/06/2015 08:28:03 using a 24 hour clock.

DDE to Excel does have a major limitation:•

it will always start at the beginning, possibly overwriting your data.

•You must remember to save the worksheet by a new name, and reopen the original worksheet
when storing new data.

See the example below to send commands to Excel to automatically save the Excel sheet, or see theexample Script that is posted at the kb.mccdaq.com to use a Script module to open your Excel sheet
before the measurement starts. The example includes a module that you can import and use without
understanding the Script module.
Search kb.mccdaq.com for DASYLab+DDE+Script or click on this link
http://kb.mccdaq.com/KnowledgebaseArticle50492.aspx

DASYLab Techniques - DASYLab DDE Examples

Page 8 of 13

Read from Excel sheet at high speed
DASYLab 2020 DDE Input 1000s-s 100b.dsb
This worksheet is configured to read from an Excel sheet at 1000 samples/second with a block size of100. Treats DDE file as a table, where the row is the data. Uses DDE Cold Link to read at specified rate.
The DDE Input module uses a generated item list to read from Excel in blocks of 100. By using a large
range, rather than reading one cell at a time, DASYLab can acquire the data from Excel at an effective
sample rate of 1000 samples/second.

The DDE connection is a "Cold Link", so that DASYLab can control the timing of the read.
The DDE Input item generation is configured to read in blocks of 100.

DASYLab Techniques - DASYLab DDE Examples

Page 9 of 13

Write to Excel sheet at high speed
DASYLab 2020 BigDDE.dsb
This worksheet is configured to write to DDE in blocks of 4096, writing the entire block as 4096 rows.
The sample rate is 11.025Ks/sec (using the Sound card driver) with a block size of 4096.
Ensure that you have created an Excel sheet that is not saved in Compatibility mode . The Excel
Compatibility mode limits the sheet to 65K rows. The maximum worksheet size for a current version ofMicrosoft Excel is 1,048,576 rows by 16,384 columns.1

Configure the DDE Output module to write to the selected sheet. DASYLab will start with the beginningof the range each time, and will overwrite existing data.
This example works because the item generation creates a large Excel range for DASYLab to write into.

As noted in the Item name field at the bottom of the dialog box, the initial range is R1C1:R4096C1. It
then increments by 4096, and the second block is R4097C1:R8192C1, and so on.

1

https://support.office.com/en-nz/article/Excel-specifications-and-limits-1672b34d-7043-467e-8e27269d656771c3

DASYLab Techniques - DASYLab DDE Examples

Page 10 of 13

Send Commands to Excel
DASYLab 2020 DDE Messages.dsb
This example uses the Action and Message modules from DASYLab Full and Pro.
Use DASYLab and the Message module to send commands to Excel using the DDE command interface.
Shows Minimize Excel Window, Restore Excel Window, as well as Save and Save As to the specified
filename.
In setting up this example, I found that the syntax of the Excel commands was a bit finicky, and I hadtrouble finding a good description of available Excel commands. These commands were determined towork by trial and error. Some commands are to Excel itself (minimize, restore) and some are to the open
Excel sheet (Save and Save As).

DASYLab Techniques - DASYLab DDE Examples

Page 11 of 13

Global Strings and Variables to Excel
DASYLAB 2020 Message_DDE_String.dsb
This example uses the Action and Message modules from DASYLab Full and Pro.
Use DASYLab and the Message module to send Global Strings and variables to a computed Excel cellrange. This example concatenates variables and strings together and sends a single line with tabseparated values.

The image below shows how the combined string was created in the Global String Advanced Definition.

DASYLab Techniques - DASYLab DDE Examples

Page 12 of 13

Start Excel with a filenameDASYLab 2020 Startup for Win10-64.DSB
This example uses the Action and Message modules from DASYLab Full and Pro.
The example was created with Excel 2020 32-bit on Windows 10 64-bit. The location for the Excel
program file is in Global string #1, and is "C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE"
in the worksheet. Change this string to reflect the correct program location on the computer.
The worksheet will start Excel with specific filename using the Action module, Start External Program.
This must be run prior to starting a worksheet with DDE. It also has an Action to Quit Excel.
You cannot use this Action in a worksheet with the DDE module because the Action on Start
Measurement will not start Excel quickly enough for the DDE modules.
This worksheet could be the first in a series of worksheets run by the Control Sequencer, where the thisworksheet does the setup, starts up Excel, etc., and subsequent worksheets then use DDE to write toExcel.

DASYLab Techniques - DASYLab DDE Examples

Page 13 of 13

The image below shows how the file name was created from the Excel program location and the Excel
sheet location.