BookmarkSubscribeRSS Feed
arnouxvr
Fluorite | Level 6

I am currently calling an Excel Macro from withing SAS which works perfectly using DDE commands.

 

*execute the excel marco;
put "[run(""&excelMarcoName."")]";

The Excel macro opens another excel file and saves it in a different location.

 

ActiveWorkbook.SaveAs Filename:= _
        "C:\Users\testuser\src\reports\new_excel_file.xlsx"

 

Currently, the path of the file is hardcoded in the Excel Macro.

 

When calling the Excel Macro is it possible to include a parameter or additional argument that will contain the location of the directory into which the file should save?

 

That parameter would then be used inside the Excel Marco to determine where to save the new file.

 

https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/154-31.pdf

 

Many thanks, 

 

 

 

 

1 REPLY 1
PhilC
Rhodochrosite | Level 12

I found this, in a SAS global forum paper.  Can you use these code snips to make it work?

 

Put '[open("'"&dir"'\'"&&FileNm&i."'")]'; /* top of p.7 */

Data _NULL_;   /* bottom of p.6 */
 File sas2xl; 
 Put '[error(false)]'; 
 Put '[save.as("'"&dir"'\'"&Table."'")]'; 
Run; 
%MACRO I

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 341 views
  • 0 likes
  • 2 in conversation