This is how I can open an excel file in vbA:
Workbooks.Open(file-path)
is there a way to specify that it should be open as read-only? The files I am opening have a password on them, and I always get the dialog that it can only be open as read only.
Does this work?
Workbooks.Open Filename:=filepath, ReadOnly:=True
Or, as pointed out in a comment, to keep a reference to the opened workbook:
Dim book As Workbook
Set book = Workbooks.Open(Filename:=filepath, ReadOnly:=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With