Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

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

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.

 

4 REPLIES 4
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.

Nikita-Puniani
7 - Meteor

Hi @MatthewP 

 

Here is a similar error message I received when I run the workflow on server. I have alteryx 2020.3 on my desktop as well as on the server. However I am able to run the workflows successfully on alteryx desktop.  The workflow has not  been scheduled as yet. Any thoughts?

 

Error message attachedError Message.PNG

ankurkumar30
6 - Meteoroid

Any body have any solution

ankurkumar30
6 - Meteoroid

Hi Mathew,

We have same problem, Can you suggest some other method to read a .xls corrupted file, 

1. we are getting .xls corrupted file.

2. we are using scripts to open and save it to .xlsx format so that our alteryx can read it.

 

In designer our workflow is working but in server its not working.

 

we have tried with Vb script and python script, both of them is not working in server but working in designer