REST service cannot access MicroSoft Word via Python

1065
2
05-25-2012 08:03 AM
RyanKelley
New Contributor II
My script calls Microsoft Word (win32com.client.Dispatch("Word.Application")) but fails.

I can run the script as myself and on the same server ArcGIS server is using, which tells me Word is on the server. But, when I run the script from the REST endpoint, I believe I get a permissions problem. Error below.  I believe permissions have been set properly for the soc/som user to access these libraries. COM issue? Thought I'd take a shot in the dark by posting here.


line 241, in wordapp = win32com.client.Dispatch("Word.Application") File "C:\Python26\ArcGIS10.0\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python26\ArcGIS10.0\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python26\ArcGIS10.0\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147024891, 'Access is denied.', None, None) (-2147024891, 'Access is denied.', None, None)

Thanks,
ryan
0 Kudos
2 Replies
RyanKelley
New Contributor II
Solution:

Have to add arcgissoc user to DCOM config on the arcgis server. Allow permissions to allow local/remote launch, local/remote activation, and local/remote access permission.

Ryan
0 Kudos
RyanKelley
New Contributor II
However, I cannot get ArcServer to populate Documents.Open(filename) - it populates this as None. ???

Sample:
import win32com.client, sys, arcpy, os, string
wordapp = win32com.client.Dispatch("Word.Application")
wordapp.Visible = 1
docname = r"Y:\blank.docx"
worddoc = wordapp.Documents.Open(docname)
arcpy.AddMessage(worddoc)

>>> worddoc = None # aka stuck

This does not happen in PyWin on the server, in ArcMap or any other way I've tried. worddoc is always populated correctly. It only fails when running from REST.

Any ideas????????????
0 Kudos