IgnoreReadOnlyRecommended not working from Python

2019-07-08 05:19发布

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条回答
我命由我不由天
2楼-- · 2019-07-08 05:50

Use instead:

xl = win32com.client.DispatchEx('Excel.Application')

This works without a dialog box for me.

查看更多
登录 后发表回答