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

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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