i ve using the library for some time now without any trouble...... but a
few days ago the script for a conversion in word from doc to pdf
respond with this error sometimes, other works fine, the error is random, i
cant figure out why occurs.

the error is:

Traceback (most recent call last):
  File
"C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py",
line 81, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operación no disponible', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\inetpub\wwwroot\ruc2docs\r2d2documento.py", line 14, in __init__
    self.save_as_('pdf')
  File "C:\inetpub\wwwroot\ruc2docs\r2d2documento.py", line 25, in save_as_
    word = win32.gencache.EnsureDispatch('Word.Application')
  File
"C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\gencache.py",
line 524, in EnsureDispatch
    disp = win32com.client.Dispatch(prog_id)
  File
"C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\__init__.py",
line 95, in Dispatch
    dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File
"C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py",
line 98, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File
"C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py",
line 83, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
pywintypes.com_error: (-2146959355, 'Error en la ejecución de servidor',
None, None)

the code to execute the conversion is:

    def save_as_(self, tipo):
        import win32com.client as win32
        from win32com.client import constants
        # self.registrar_conversion()
        word = win32.gencache.EnsureDispatch('Word.Application')
        doc = word.Documents.Open(self.ruta, ReadOnly=True,
AddToRecentFiles=False, Revert=True, Visible=False)
        doc.Activate()
        if tipo == 'pdf':
            word.ActiveDocument.SaveAs(self.ruta[:-4] + '.pdf',
FileFormat=constants.wdFormatPDF)
        elif tipo == 'docx':
            word.ActiveDocument.SaveAs(self.ruta[:-4] + '.doc',
FileFormat=constants.wdFormatXMLDocument)
        doc.Close(SaveChanges=constants.wdDoNotSaveChanges)
        word.Quit()

Thank you!


*----------------------------------------*


*Martín Trujillo Raddatz         Puerto Montt - Chile            Teléfono:
+56 9 96427814 *
*----------------------------------------*
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to