current position:Home>pywintypes. com_ Error: (- 2147023728, 'element not found', none, none)

pywintypes. com_ Error: (- 2147023728, 'element not found', none, none)

2022-02-03 00:38:50 CSDN Q & A

The phenomenon and background of the problem

Computer update ,EXCEL Something unusual happened , reinstall OFFICE2016 in the future , use python open EXCEL Report errors . meanwhile CAD Can't open EXCEL 了 . It has been used normally before .

import xlwings as xwimport os#  Implicitly open EXCEL surface app = xw.App(visible=False, add_book=True)# Original worksheet old_wb = xw.Book(r'G:\ Calculation of quantities \1604.xls')old_sht = old_wb.sheets[' Table 3A ']# print(old_sht.name)first_col = 12   #  From page... In the original worksheet 12 Column starts writing data counts = 0   # Worksheet count #  Traverse all the... Under a folder EXCEL file for file in os.listdir(r'G:\ Calculation of quantities \1604 Data sheet '):    f = 'G:/ Calculation of quantities /1604 Data sheet /' + file    wb = xw.Book(f)    shts = wb.sheets
Operation results and error reporting contents
Traceback (most recent call last):  File "G:/ Calculation of quantities / Calculate the quantities / Write the quantities into the original batch EXCEL in .py", line 6, in <module>    app = xw.App(visible=False, add_book=True)  File "C:\Users\zhong\AppData\Local\Programs\Python\Python37\lib\site-packages\xlwings\main.py", line 209, in __init__    self.impl = xlplatform.App(spec=spec, add_book=add_book, visible=visible)  File "C:\Users\zhong\AppData\Local\Programs\Python\Python37\lib\site-packages\xlwings\_xlwindows.py", line 313, in __init__    self._xl = COMRetryObjectWrapper(DispatchEx('Excel.Application'))  File "C:\Users\zhong\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client\__init__.py", line 113, in DispatchEx    dispatch = pythoncom.CoCreateInstanceEx(clsid, None, clsctx, serverInfo, (pythoncom.IID_IDispatch,))[0]pywintypes.com_error: (-2147023728, ' Element not found .', None, None)
My solution ideas and tried methods

Tried to change EXCEL Registry method , Change permissions , Neither. .

What I want to achieve



Refer to the answer 1:

Check the registry OFFICE2016 Whether you have successfully registered in it , This is caused by a registry error , Use the cleaner below to clear the registry and reinstall it again
https://download.csdn.net/download/qq657441718/10312805




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030038483365.html

Random recommended