08-26-2016 09:26 AM - edited 08-26-2016 09:27 AM
Hi All - I am having a hard time making the VB script work from EG. We are migrating from PC SAS to SAS EG, but the below piece of code doesnt work. Any suggestions?
Below macro runs VBScript vbscript.vbs. PFA script. This vbscript reads ‘test.doc’ and creates vbscript.txt file.
filename vbscript pipe "cscript vbscript.vbs" console=min;
infile vbscript ;
· When we ran this code from BASE SAS 9.4, the file vbscript.txt is created successfully.
· When we ran script ff44f002.vbs from command prompt, the file vbscript.txt is created successfully.
· But when we ran this macro code from SAS Enterprise Guide, the file file vbscript.txt is not getting created. We getting below note in the log
C:\Documents\vbscript.vbs(8, 1) Microsoft Word: This command is not available because
no document is open.
Content of vb script is as below.
set objwd = wscript.createobject("Word.Application")
08-26-2016 01:50 PM
By any chance does your new EG environment involve a server? The file paths would all have to be something the server can use. This may mean moving some of your files to a shared network location or another approach that lets both you as user and the server read and write files to a location.
09-13-2016 04:43 PM
Yes, our new EG environment is connecting to a remote windows server. we are actually creating the file at a shared location, but still not able to exeucte the script.
08-26-2016 08:20 PM
It looks like your VB script is trying to open an MS Word document. If EG is connecting to a remote Windows SAS server there is no console environment for Word to open in hence your script fails. I strongly suspect your script will only work with local SAS on your PC.
09-13-2016 04:39 PM
Sorry for the late response. Yes, EG is connecting to a remote server and I beleive that is the reason the script fails. Is there any other way to achieve this?
Please let me know.
09-13-2016 07:09 PM
09-14-2016 10:46 PM - edited 09-15-2016 01:13 AM
EG is very limiting in terms of what you control compared to SAS. One of the reasons is that everything now runs on a server.
Try starting MS word like this to see what happens. It should appear in the list of processes on the server.
filename TEST pipe '____path_to_office___\winword.exe'; data _null_; infile TEST; input; put _infile_; run;
The /x switch may help, even though we are not doing DDE here (untested). See
09-16-2016 12:32 PM
I see this in the log file. Also, I dont see an instance of word process opening on the server.
NOTE: The infile TEST is:
Unnamed Pipe Access Device,
PROCESS=C:\Program Files (x86)\Microsoft Office\Office14\winword.exe,