Using SAS DDE and VB code

Regular Contributor
Posts: 160

Using SAS DDE and VB code



I want to know some good resources for achieving a output where i need to create a output using sas DDE and VB code.I want to create a template in excel and when sas outputs the data the template can be used to create the output.


Any help would be appreciated

Posts: 8,149

Re: Using SAS DDE and VB code

You don't need DDE for that and, in fact, don't even have to write the VB code. A couple of us already did that for you.


Take a look at the freely available macro at:



Art, CEO,


Regular Contributor
Posts: 160

Re: Using SAS DDE and VB code

Wow that's awesome.I am including this macro in the job through %include.Usually i do remote submit but this macro didn't work while i did remote submit.I just submited the job then it ran.I am using macro variables in the folder destination for creating the output

I want to create the file on shared drive not on my local drive


%INCLUDE "\\corp\....\";


%exportxl( data=&t1._Data


1) when i did remote submit the job didn't work.Why/

2) I submitted the job but got the following error

ERROR: Connect: Class not registered
ERROR: Error in the LIBNAME statement.


What mistake I am doing?

Posts: 8,149

Re: Using SAS DDE and VB code

I've never used rsubmit to run the macro, thus can't be sure of the reason. One possibility, though, is that you'll need to include the server_path parameter. It's described in the paper that's on the same page as the macro.


Art, CEO,


Super User
Posts: 23,296

Re: Using SAS DDE and VB code

I did a presentation on this a few years ago, Coordinating Complex Reports Using SAS.


We've switched to using @art297's macro instead of DDE for exporting in most spots these days. 

We still use DDE to automatically convert the excel spreadsheet into PDFs and creating graphs in Excel. Sometimes the number of graphs can vary, not accounted for in this presentation or the link to the reports below. The VB code is embedded into the Excel workbook. 


The steps in my process were:


1. Copy the template to a new file with new name for the report. This workbook maintains the embedded VB code. 

2. Export the data from SAS to Excel, as required. Multiple steps may be required here depending on the number of tables needed.

3. Use DDE to open and run the VB code for graphs

4. Convert Excel file to PDF sections, using DDE + VB

5. Go to Step 1 & 100+ for custom reports with formatting and customized texts. 


Reports are here if you're curious Smiley Happy


Good Luck!




Ask a Question
Discussion stats
  • 4 replies
  • 3 in conversation