Hi All -
I am trying to automate the steps of process flow which includes SAS and SAS EG tasks(plug-ins) and Excel VBA macros.
Here i would need help to understand how to run a macro which is located in excel file.
Example: sample.xlsm file has the macro with the name 'my_macro' .
I would need to run this in windows command line by using .bat file.
I have done some googling I could not find proper solution.
Thanks in advance!!
Thank You,
Durga.
Proceed as for example described here: http://www.lexjansen.com/pharmasug/2005/CodersCorner/cc21.pdf
Your code could look like:
Options XSync;
Data _NULL_;
rc=System('Start Excel');
x=sleep(3);
run;
Filename EXCEL DDE 'EXCEL|SYSTEM';
Data _NULL_;
File EXCEL;
Put '[Open("<Path>\sample.xlsm")]';
Put '[Run("My_Macro")]';
Put '[Quit()]';
Run;
Filename EXCEL Clear;
Do be aware though, user24feb, DDE is old technology, no longer supported by M$. It may/may not work in future, and wouldn't have all the functionality of later (at least 2007/2013 version) releases.
My organization has identified at least one application, Cisco Jabber, that will interfere with SAS DDE connections to Excel and other "legacy" software. This can be worked around by killing the process using Task Manager (closing the application leaves a process running). I wouldn't be surprised to find other applications that do the same.
You would need to investigate VB scripting. In your VB script you would need to open an office object. Then you can use that object to execute various things which would normally be done within Office applications.
Here are some links to help you however this is out of scope of a SAS forum:
http://www.pcreview.co.uk/forums/opening-excel-spreadsheet-within-vbscript-t965331.html
Or from Visual Basic app:
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.