Desktop productivity for business analysts and programmers

Invoke VBA command or run VBA macro suning SAS EG

Reply
Occasional Contributor
Posts: 16

Invoke VBA command or run VBA macro suning SAS EG

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.

Esteemed Advisor
Esteemed Advisor
Posts: 7,256

Re: Invoke VBA command or run VBA macro suning SAS EG

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.

Occasional Contributor
Posts: 16

Re: Invoke VBA command or run VBA macro suning SAS EG

Sorry DDE is not available in SAS EG

SAS Super FREQ
Posts: 274

Re: Invoke VBA command or run VBA macro suning SAS EG

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';

Occasional Contributor
Posts: 16

Re: Invoke VBA command or run VBA macro suning SAS EG

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

Ask a Question
Discussion stats
  • 4 replies
  • 676 views
  • 0 likes
  • 3 in conversation