Vba: how can I open a book programmatically as read only?

here is how i can open excel file in vbA:

Workbooks.Open(file-path) 

Is there a way to indicate that it should be read-only? opening im files have a password on them, and I always get a dialog that it can be opened as soon as read.

+6
vba excel
source share
2 answers

It works?

 Workbooks.Open Filename:=filepath, ReadOnly:=True 

Or as indicated in a comment to save a link to an open book:

 Dim book As Workbook Set book = Workbooks.Open(Filename:=filepath, ReadOnly:=True) 
+24
source share

Check the language link:

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) 
+10
source share

All Articles