Thanks! Finally the problem is Word app, i try repair and reinstall, din not work. its seems that a virus may be affecting it, we are now moving the scripts to other machine ir orden to determine if the proble is Word or other thing.
*----------------------------------------* *Martín Trujillo Raddatz Puerto Montt - Chile Teléfono: +56 9 96427814 * *----------------------------------------* El mar, 30 may 2023 a las 17:29, Steven Manross (<ste...@manross.net>) escribió: > While I’ve done word automation in the past, is it possible that there’s > any issues with the word application installation itself? Or maybe you > might have multiple scripts trying to open/write files simultaneously? > > > > As well, I might consider looking at task manager on your web server to > see if there are a lot of processes for word that might create some sort of > bottleneck, or concurrency issue. > > > > I know when I am doing some selenium work with Google Chrome, sometimes it > leaves a rogue Chrome process running, and as a result, the server gets > bogged down and can’t do what it’s supposed to very well because of all the > chrome processes left over from failed python script instances. > > > > Typically the error you are seeing might point to a problem with some > variable you believe should be an expected value, but in this case, it’s > None, or another non-standard value… Typically, I will log that kind of > data from my classic asp web pages to understand the problem more. > > > > In your case, I might start by writing the file name (self.ruta) to a log > file in case it’s blank, or has special characters in it that could be > causing issues. > > > > I hope this helps. The error messages you are seeing are quite generic, > and reference a problem with rendering the webpage and not necessarily a > python specific error. > > > > Steven > > *From:* python-win32 <python-win32-bounces+steven=manross....@python.org> *On > Behalf Of *Martín Trujillo Raddatz > *Sent:* Monday, May 29, 2023 12:05 PM > *To:* python-win32@python.org > *Subject:* [python-win32] unknow solution > > > > 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