At work we have a old script that has become broken over the years. To keep it short we PSSE to create a model and want to export the results from the study into an Excel file. I am currently getting Wincom32 errors including "Operation Unavailable" and "Server Execution Failed" when trying to create a blank Excel. I have posted the code and errors below.
We currently use PSSE33 which uses Python 2.7. I have access to PSSE34 and 35 and Python 3.7 and 3.9 but I tested those and get the same errors. I suspected the issue was because our company has rolled out Office 365 and Excel version 16 64 bit and the script was having issues since Python 2.7 is 32 bit but I'm not sure if that's really the issue.
On top of the "Server Execution Failed" error I was also sometimes getting a "Operation Unavailable" error as well.
#Adding PSSBIN to the sys path. This allows us to look through this folder for imported modules.
PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psspy
import psspyc
import win32net
import win32com.client
import win32com.client.dynamic
import redirect
import types
import datetime
import time
import shutil
import math
import glob
#Creates an empty instance of Excel`enter code here`
xlApp = win32com.client.dynamic.Dispatch("Excel.Application")
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 127, in Dispatch
IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch,userName,clsctx)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2146959355, 'Server execution failed', None, None)