问题
I have an excel workbook I need to open from python in a writable mode. The workbook is set up to have the prompt for a read only recommendation and this cannot be removed.
I am using the following:
import win32com.client
xl=win32com.client.Dispatch("Excel.Application")
filepath = 'C:\Users\FullFilePath.xlsm'
xl.Workbooks.Open(Filename=filepath, ReadOnly=False, IgnoreReadOnlyRecommended=True)
It opens the file, but it's still popping up the dialog asking if I want to open in read only. Is it possible to cancel that dialog?
回答1:
Use instead:
xl = win32com.client.DispatchEx('Excel.Application')
This works without a dialog box for me.
来源:https://stackoverflow.com/questions/43101074/ignorereadonlyrecommended-not-working-from-python-when-opening-excel-workbook