I'd like to transform an excel (.xlsx) file to a .pdf file. I found this code:
from win32com import client
xlApp = client.Dispatch("Excel.Application")
books = xlApp.Workbooks.Open('C:\\Users\\gregd\\PycharmProjects\\excel\\data.xlsx')
ws = books.Worksheets[0]
ws.Visible = 1
ws.ExportAsFixedFormat(0, 'C:\\Users\\gregd\\PycharmProjects\\excel\\data.pdf')
But I'm getting this error:
Traceback (most recent call last):
File "C:/Users/gregd/PycharmProjects/excel/idea.py", line 3, in <module>
books = xlApp.Workbooks.Open('C:\\Users\\gregd\\PycharmProjects\\excel\\data.xlsx')
File "C:\Users\gregd\PycharmProjects\excel\venv\lib\site-packages\win32com\client\dynamic.py", line
527, in __getattr__
raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: Excel.Application.Workbooks
The code seems to work for others, but not for me. Any ideas as to why this is?