Dec-10-2023, 06:34 PM
To start - I am a novice at Python.
I have a created a "tool" I use for my work daily. It includes the ability to create Excel workbooks that I use for notes etc. I am updating this tool by simply adding the ability to create update and show a third excel workbook. The first two work well and have for years. This new third (createQstn) gives me an tkinter attribute error that "worksheet has no attribute 'save'". However I am defining it as "Workbook()". The "filepath3" variable works for every other function that uses it, AND if I create the workbook in excel and save it correctly, I will get my print response "exists" when I hit my "createQstn" button. The only issue is that it will not create this workbook and gives me the error, if it does not already exist. The two previous functions create workbooks without error, and I can't see what I may have done different. Any help would be much appreciated. I am including the code section that produces the error. If it is possible the issue is earlier or later somehow, please let me know and I will post the full code.
Sean
I have a created a "tool" I use for my work daily. It includes the ability to create Excel workbooks that I use for notes etc. I am updating this tool by simply adding the ability to create update and show a third excel workbook. The first two work well and have for years. This new third (createQstn) gives me an tkinter attribute error that "worksheet has no attribute 'save'". However I am defining it as "Workbook()". The "filepath3" variable works for every other function that uses it, AND if I create the workbook in excel and save it correctly, I will get my print response "exists" when I hit my "createQstn" button. The only issue is that it will not create this workbook and gives me the error, if it does not already exist. The two previous functions create workbooks without error, and I can't see what I may have done different. Any help would be much appreciated. I am including the code section that produces the error. If it is possible the issue is earlier or later somehow, please let me know and I will post the full code.
def createQstn(): print(filepath3) isFile = os.path.isfile(filepath3) if isFile == False: QstnsWB = Workbook() QstnsWB = QstnsWB.active QstnsWB['A1'] = '#' QstnsWB['B1'] = 'Date' QstnsWB['C1'] = 'Question' QstnsWB['D1'] = 'Answer' QstnsWB['E1'] = 'Done' QstnsWB.save(filepath3) print("created") print("exists")the error:
Error:Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\Lib\tkinter\__init__.py", line 1948, in __call__
return self.func(*args)
^^^^^^^^^^^^^^^^
File "C:\Users\SeanL\Python Scripts\360Helper5.0.py", line 102, in createQstn
QstnsWB.save(filepath3)
^^^^^^^^^^^^
AttributeError: 'Worksheet' object has no attribute 'save'
Thanks for any help. Sean