Unformatted text preview: let we can do things like open and close Word documents. In this code example,
we open a document name stored as a macro variable. After we do something, we close the active document and
exit Word. It’s not required that the DDE-doublet be referenced inside a DATA _NULL_ step but to make the code
more readable and intuitive a best practice is to give it its own step. 3 SAS Global Forum 2013 Foundations and Fundamentals data _null_;
put '[FileOpen.Name = "'"&_document"'"]';
< do something >
put '[fileclose 2]';
A DDE-triplet is a three-part specification that opens a link to a specific location in an external data file. It takes the
form of 'executable-file-name|data-file-location!Data-range-within-the-file'. A DDE-triplet requires that the data source
be open before the fileref is used… that’s why we use a doublet to first open the W ord document and then close it when we’re finished.
filename campInfo dde "Winword|&_document!general_campaign_info" notab; In this DDE-triplet, W inword specifies that the MS Word executable will handle references to the fileref. The macro
variable &_document following the pipe contains the fully-defined path and filename with extension of the Word
document we want to read, and the location within the document—the bookmark—follows the bang ( ! ) delimiter.
The notab options performs the same function as it does when used with an INFILE statement.
Each bookmark needs its own fileref, so a document with four bookmarks would need four FILENAME statements —
filename campInfo dde "winword|&_document!general_campaign_info" notab;
si dde "winword|&_document!standard_inclusions" notab;
seb dde "winword|&_document!standard_exclusions_binary" notab;
sev dde "winword|&_document!standard_exclusions_value" notab; LEVERAGING SAS AND WORD—A CODE GENERATOR FOR ORACLE QUERIES
In database marketing it’s common for a campaign...
View Full Document
- Visual Basic for Applications, SAS Global Forum