DDEEXPORT procedure

Sends data or commands to a Dynamic Data Exchange server, PC Windows only (D.B. Baird).


Options

SERVER = text
Name of DDE Server; default Excel

TOPIC = text
Name of DDE Topic

ITEM = text
Name of DDE Item; default R1C1

OUTFILE = text
Name of Excel or Quattro Pro file

SHEETNAME = text
Name of Excel or Quattro Pro sheet within the file

COLUMN = text or scalar
Name or number or column of the first cell to write to, either as a text (e.g. 'A', 'AN') or a number (e.g. 1, 40)

ROW = text or scalar
Number of the row of the first cell to write to, i.e. '2', or 2

LABELLING = text
What labels to write to the DDE server (rows, columns) default rows, colu

METHOD = string
Whether the DATA parameter specifies a text which is send as a series of commands to the DDE server or data values (data, commands); default data


Parameter

DATA = identifiers
The data structures to be written to the DDE server, or a text containing the commands to be sent to the server


Description

The data to be written via DDE is specified by the DDE triplet: server, topic and item. For convenience this has been broken down to the components OUTFILE, SHEETNAME, COLUMN and ROW for the two common spreadsheets Excel and Quattro Pro for Windows. For Excel/QPW also only the first cell need be provided and GenStat will automatically work out the correct item range given the size of the DATA structures passed to DDEEXPORT.

   When a command is being sent to a DDE server (METHOD=command), the DATA must be a text, and only the SERVER and TOPIC options need to be set.

   The LABELLING option allows you to only send the required aspects of the data to the DDE server.

   The TOPIC for Excel has the format '[<FileName>]<SheetName>' e.g. '[D:/Work/Data.XLS]Data Summary', and the ITEM has the numerical format R<n1>C<n2>:R<n3>C<n4> e.g. 'R2C3:R25C5' or the format '<Column letter><rowno>:<Column letter><rowno>' e.g. 'C2:E25'.

   The TOPIC for QPW has the format 'FileName' e.g. 'D:/Work/Data.WB3', and the ITEM has the format of 'Sheet:<Column letter><rowno>..<Column letter><rowno>' e.g. 'B:C2..E25'.

   The use of DDEEXPORT is illustrated in the following examples. To write three variates to a QPW file in the first sheet in cells B2..D8:

DDEEXPORT [SERVER=QPW; TOPIC='C:\\WORKBOOK.QPW';\

  ITEM='A:B2..D8'] X,Y,Z

To write a matrix to Excel in the cells starting at D5:

DDEXPORT \

  [topic='[D:\\\\DATA\\\\RESULTS.XLS]Sheet2';item='D5'] VC

To send a set of DDE commands to Excel:

TEXT CMDS; !T('[OPEN(""C:\\\\TRIAL\\\\DATA.XLS"")]', \

  '[WORKBOOK.INSERT(1)]', \

  '[SELECT(""A4..D8"")]')

DDEXPORT [METHOD=command] CMDS

Excel DDE commands are a subset of the Excel 4 macro language. The format of the commands are [Function(arg1,arg1,...)]. text strings in the arguments are quoted with double quotes (e.g. "A1"). The following is a subset of Excel commands which may be useful:

    [APP.RESTORE()]
Restore the Excel window

    [APP.MINIMIZE()]
Minimize the Excel window

    [APP.ACTIVATE()]
Make Excel the application with focus

    [OPEN("filename")]
Open a workbook in Excel

    [WORKBOOK.INSERT(1)]
Insert an new workbook

    [WORKBOOK.SELECT("sheetname")]

    
Make the named sheet the current sheet

    [WORKBOOK.DELETE()]
Delete the current sheet

    [SELECT("object")]
Select the cells/column/rows specified in object

    [SORT(1,"R1C1",1)]
Sort the selected cells using key in specified cell

    [SAVE()]
Save the current workbook

    [SAVE.AS("filename",1)]

    
Save the current workwork as a new file

    [CLOSE(1)]
Close and save the current workwork (0 = close but don't save)

Complete details are available in the Windows help file Macrofun.hlp available on the Microsoft Internet site.

   (Note: DDEEXPORT replaces the procedure %DDE from earlier editions of GenStat.)

 

Options: SERVER, TOPIC, ITEM, OUTFILE, SHEETNAME, COLUMN, ROW, LABELLING, METHOD.

Parameter: DATA.


Action with RESTRICT

Restrictions on the structures are ignored and all data will be sent to the DDE server. However, if the restrictions on the structures are not consistent, a fault will occur.