We are aware of an issue with the Search bar. Please use Advanced search for the time being while we troubleshoot. Thanks for your patience as we work on improving the community!

Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.

Using pywin32 to Refresh Excel Connection, Works in Designer but Fails in Scheduler

zhagenbush
5 - Atom

All,

 

I wrote a simple python script using pywin32 (Alteryx python node did not like when I used win32com itself) that does the following:

 

#################################
from ayx import Package
Package.installPackages(['pywin32'])


#################################
from ayx import Alteryx


#################################
import win32com.client
#%%
xlapp = win32com.client.DispatchEx("Excel.Application")
wb = xlapp.Workbooks.Open("My file here")
wb.RefreshAll()
xlapp.CalculateUntilAsyncQueriesDone()
xlapp.DisplayAlerts = False
wb.Save()
wb.Close(True)
xlapp.Quit()

 

When I run this in Designer, it runs fine. I open a file that has a connection to Sharepoint, refresh the connection in this spreadsheet, save the file, and then have a separate branch of Alteryx pull the data elsewhere. When I attempt to schedule this workflow, it fails with the following error:

 

Error: Tool #1: ---------------------------------------------------------------------------
com_error Traceback (most recent call last)
<ipython-input-3-130776a91de8> in <module>
1 import win32com.client
2 #%%
----> 3 xlapp = win32com.client.DispatchEx("Excel.Application")
4 wb = xlapp.Workbooks.Open("My file here")
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\win32com\client\__init__.py in DispatchEx(clsid, machine, userName, resultCLSID, typeinfo, UnicodeToString, clsctx)
111 serverInfo = (machine,)
112 if userName is None: userName = clsid
--> 113 dispatch = pythoncom.CoCreateInstanceEx(clsid, None, clsctx, serverInfo, (pythoncom.IID_IDispatch,))[0]
114 return Dispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
115
com_error: (-2146959355, 'Server execution failed', None, None)

 

Has anyone seen this error before or how to work around it in Scheduler? Any assistance is greatly appreciated.

 

1 REPLY 1
MatthewP
Alteryx
Alteryx

Hello!

 

Thank you so much for the post on community about pywin32. This behavior is known interaction with pywin32 and our scheduler and even Server/Gallery. It boils down to how those products run workflows vs when they are ran in Designer itself. Opening a third party software like excel while running in scheduler is not fully supported, there are have some customers that have gotten it to work. I have seen some customers have success with the xlrd library (the newer version of this library cannot support files that are not xls), the older versions of this library can support xlsx though.