Hello there,
Based on the VBS script generated when we choose the "Schedule" option on EnterpriseGuide our team is trying to automate the exeuction os SAS programs on Python by using PyWin32/win32com.
In my colleague's computer it runs fine, but in mine, I get this error:
Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch IDispatch = pythoncom.connect(IDispatch) pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\Users\xxxxxxx\Desktop\test.py", line 4, in <module> sas = EnsureDispatch('SASEGObjectModel.Application.7.1') File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\gencache.py", line 527, in EnsureDispatch disp = win32com.client.Dispatch(prog_id) File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147024809, 'The parameter is incorrect.', None, None)
When I've tried using makepy to generate a py model of the object, I've got this message:
Could not locate a type library matching 'SASEGObjectModel.Application.7.1'
But by using this simple VBS script:
Set app = CreateObject("SASEGObjectModel.Application.7.1") WScript.echo app.Name
i'm able to see a message box with "Enterprise Guide" written on it. So it seems the COM object is correctly registered on my system.
I would be glad for any kind of help 😃
No. BLAME THE PYTHON was my natural response, but I suppressed it here in the interest of inter-tool peace.
Bitness matters. Are you using 32- or 64-bit SAS Enterprise Guide? Whatever the answer, the Python runtime would need to match.
When you successfully run with VB Script, what's the runtime? Is it the 32-bit version:
c:\Windows\SysWOW64\cscript.exe
Or the 64-bit version (yes, don't let that "system32" folder name throw you off...)
c:\Windows\System32\cscript.exe
Both Python and SAS are 64-bit, as you can see below:
About the VBScript, if I try to run it directly with the cscript.exe from the SysWOW64 folder, it throws me an error, while the one at System32 runs fine, so I'm guessing I'm using the 64-bit one as well.
thanks
It is possible that the SAS EG automation model isn't properly registered on your machine -- but then I would not expect the VB script to work.
(Check the above paths to make sure they match where things are on your machine.)
Ran both commands on my computer. Just had to change the 2nd one to remove the "\k\" from the path (in "Framework\k\v4.0.30319").
Both ran without errors, apparently
But still getting the same error.
Okay, back to basics. Can you use your Python environment to create an instance of a different object? Like "Word.Application"?
Sorry for taking so long to answer, but yes, I'm able to create instances of any office application's object using python.
As this is working for your colleague, I'd compare a few things.
Check output of this command (from a command prompt):
32-bit EG:
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{6517AA37-C08D-4721-9723-BEBA806C56F9} /s
64-bit EG:
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{6517AA37-C08D-4721-9723-BEBA806C56F9} /s
So, as far as I can tell, they are both the same, I asked my colleague to run those commands, and it didn't find the WOW6432Node's key in his computer. So probably my Dispatch is trying to read from the 32-bit DLL, right?
The WOW6432 entry indicates a 32-bit version of EG that is registered. If that's a difference between you, then one of you has 32-bit EG and one has 64-bit.
I just looked into my ProgramFiles(x86) folder and apparently there was a 32-bit SAS installation there (But it's not there anymore, the 32-bit Scripting dll doesn't even exist anymore). Is there a way to unregister this object? (I've tried deleting the registry keys, but apparently this is not the solution).
Going a bit off the beaten path here, but...
SEGScripting.dll (and most of EG, actually) is the same for 32-bit and 64-bit. You *should* be able to unregister the 32-bit version of these by using regasm with the /u option (based on the command I supplied earlier). However, make sure you run the 32-bit version of regasm.exe. Actually, I might have steered you wrong with the command I supplied -- because I pointed you to /Framework and not /Framework64 for regasm,
So...maybe retry that regasm command:
So I've tried (without the 64 after Framework, and with /u):
Then (with the 64, without /u):
But I'm still getting the error. Tried restarting the PC, but nothing...considering that maybe a possible solution is just to ask the company to reinstall SAS on my PC (since I cannot do it myself)...which I'm not even sure will solve the problem.
It's just so bizarre, since everything seems correctly setup, it works with VBS, it works on my colleagues' PCs...
If it works with 64-bit VB Script, then I don't think it's the SAS Enterprise Guide install. But...at this point I'm running low on ideas.
First of all, thanks so much for everything you've tried here with me,
So, my Python installation came from the Anaconda package (Which, in my colleagues' computer is not a problem at all). I've tried and
installed a fresh python installation, installed pywin32 and I managed to create the SAS object without problems. Do you have any idea why that may be?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.