| SAS Companion for the Microsoft Windows Environment |
When you define a fileref to use with DDE, the DDE-triplet argument refers to the DDE external file.
The DDE triplet is application-dependent and is different for every application you run. The DDE triplet may be referenced in the
application's documentation or you can use the SAS System to determine the DDE triplet.
The triplet takes the following
form:
|
'application-name|topic!item'
|
|
where:
-
application-name
-
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.
-
topic
-
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.
-
item
-
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 package 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 invoked 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. ![[cautend]](../common/images/cautend.gif)
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"
!MARK1' notab;
The application-name is
winword, the topic is
"c:\temp\testdde.doc", and the range is
!MARK1.
This following example assumes you are using Microsoft Excel 5.0 or greater.
Suppose you want to use SAS to populate the first 4 rows and 2
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.
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. ![[cautend]](../common/images/cautend.gif)
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.