- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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: