BookmarkSubscribeRSS Feed
anu_ha
Calcite | Level 5

Is there any way of running VBA macro using SAS EG. I know in base sas it can be done using DDE. But how to do that using SAS EG. I am using EG 5.1.

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

VB for Applications is a programming environment within the office application.  DDE is a connector with which you can send code into an open Office Component.  You should be able to do the same in EG, though I don't use it.

I would however question why you would want to do this.  If a VBA macro needs to be run, set it to run On_Open, that way it will be run once the file is opened, rather than the need to push it to do it immediately.  Otherwise a more complete image of what you are trying to achieve is needed.

anu_ha
Calcite | Level 5

Sorry DDE is not available in SAS EG

CaseySmith
SAS Employee

You cannot use DDE from EG (which connects to "headless" SAS sessions), since DDE relies on Windows messages and requires the SAS session to run in a windowing environment (and on the same machine as the process it is communicating with).


However, you can run VBSCript from EG if X commands are allowed on your server.  For example:


/* write the vbs file */
data _null_;
file 'c:\temp\test.vbs';
put "Set objFSO=CreateObject(""Scripting.FileSystemObject"")";
put "outFile=""c:\temp\test.txt""";
put "Set objFile = objFSO.CreateTextFile(outFile,True)";
put "objFile.Write ""test string"" & vbCrLf";
put "objFile.Close";
run;

/* execute the vbs file */
X 'c:\temp\test.vbs';


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

anu_ha
Calcite | Level 5

Can excel Libname be used to invoke VBA macro in Excel?

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 2966 views
  • 0 likes
  • 3 in conversation