Using Dynamic Data Exchange under Windows |
When you define a fileref to use with DDE, the DDE-triplet argument refers to the DDE external file.
Using the DDE Triplet |
The DDE triplet is application-dependent and is different for every application you run. For information on an application's DDE triplet, see the application's documentation.
The triplet takes the following form:
|
is the executable filename of the server application. For example, the application-name for Microsoft Word is winword , and for Microsoft Excel it is excel .
is the topic of conversation (between SAS and the DDE server application). This is typically the full path filename of the document or spreadsheet with which you want to share data.
is the range of conversation specified between the client and server applications. In spreadsheet applications, this is usually a range of cells. For document-based applications (for example, Microsoft Word), the item is something that defines a location in the document, such as a bookmark.
Valid values for all of these arguments vary depending on the server application. A software application supporting DDE as a server should list acceptable values for the triplet information in documentation supplied with the application.
Note: The server application must be started before trying to communicate with it using DDE. Also, the DDE triplet format might differ among different applications and among different versions of the same application.
For example, in order to place text into a Microsoft Word document TESTDDE.DOC located at C:\TEMP with a bookmark named NUMBER, you could use this code:
filename test dde 'winword|"c:\temp\testdde.doc" !NUMBER' notab;
The application-name is winword , the topic is "c:\temp\testdde.doc" , and the range is !NUMBER .
The following example assumes you are using Microsoft Excel 5.0 or greater.
Suppose you want to use SAS to populate the first four rows and two columns of the Microsoft Excel spreadsheet named Sales Data stored in C:\EXCEL\SALES.XLS. You would use the following code:
filename test dde 'Excel|c:\excel\ [Sales.xls]Sales Data!R1C1:R4C2'
The application-name is Excel , the topic is c:\excel\[Sales.xls] Sales Data , and the range is R1C1:R4C2 .
If your server application is able to copy the DDE-triplet to the Windows clipboard, you can display the DDE-triplet in SAS. To do this, select the information in the server application and copy it to the Windows Clipboard. Return to SAS and select Solutions Accessories DDE triplet.
Controlling Another Application Using DDE |
DDE server applications support certain commands that you can issue by using a DDE link to control the application. To use these commands, use the special topic name SYSTEM in the DDE triplet and leave the item name blank. You can then use the INPUT statement for input from an application and the PUT statement to issue commands to the server application.
For those DDE server applications that do not recognize the SYSTEM topic name, you can specify the COMMAND option in the FILENAME statement you use to define the DDE link. When you specify the COMMAND option, you do not specify the item name in the DDE triplet.
Note: With SAS/AF software and OLE automation, you can automate any Windows application that supports OLE 2.0 as a server. For more information about using SAS and OLE, see Automating OLE Objects and Applications.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.