I tried to convert .xls to .xlsx
this is my code:
import os
address = os.getcwd()
import win32com.client as win32
fname = address + "\\Bundles.xls"
fname2 = address + "\\searchresults.xls"
excel = win32.gencache.EnsureDispatch('Excel.Application')
excel2 = win32.gencache.EnsureDispatch('Excel.Application')
wb = excel.Workbooks.Open(fname)
wb5 = excel.Workbooks.Open(fname2)
wb.SaveAs(fname+"x", FileFormat = 51)
wb5.SaveAs(fname2+"x", FileFormat = 51) #FileFormat = 51 is for .xlsx extension
wb.Close()
wb5.Close() #FileFormat = 56 is for .xls extension
excel.Application.Quit()
excel2.Application.Quit()
print('File .xls convert .xlsx successful!!')
Then I got error:
Traceback (most recent call last):
File "c:\Users\shenshuaic\Desktop\SFP Program\win32test.py", line 10, in <module>
import win32com.client as win32
File "C:\Users\shenshuaic\AppData\Local\Continuum\anaconda3\lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: DLL load failed: The specified procedure could not be found.
I have already reinstall pywin32. It is still happen
Scripts
directory, and runpython -B pywin32_postinstall.py
– Pantechnicon