tags:

views:

60

answers:

3

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 im opening have a password on them and i always get the dialog that it can only be open as read only.

+2  A: 

Does this work?

Workbooks.Open Filename:=file-path, ReadOnly:=True
LittleBobbyTables
+2  A: 

Check out the language reference:

http://msdn.microsoft.com/en-us/library/aa195811(office.11).aspx

expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad)
buckbova
A: 

I am not sure if that is the right way to do it. I don't fully understand your requirements. I tend to protect the workbook but then have the code unlock and then lock when it wishes to operate on the Workbook.

ActiveWorkbook.Protect
activeworkbook.Unprotect
Paddy