0

I need to open an xls file from python using win32com as read-only and I seem not be getting the effect I desire

Here is what I do:

import win32com

xl = win32com.client.Dispatch('Excel.Application')
wb = xl.Workbooks.Open(file_path, ReadOnly=1) # 1 is for readonly

The workbook opens and data shows; however, the file is not opened as read-only.
per MSDN argument signature should trigger read-only effect but it does not.

Anyone had to deal with similar problem before?

JavaFan
  • 1,295
  • 3
  • 19
  • 28

1 Answers1

2

ReadyOnly is a third parameter according to the documentation. Pass None for the UpdateLinks and True for ReadyOnly.

wb = xl.Workbooks.Open(file_path, None, True)
EylM
  • 5,967
  • 2
  • 16
  • 28
  • 1
    @EyIM, Thank you very much! that was exactly what I was missing. I have gotten way too used to named parameters in python...Thanks again!! – JavaFan Aug 13 '19 at 17:18