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?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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