Opening Workbook as Read Only and using ".Activate"

J

John Brenner

I have code that opens the file and activates it:

Workbooks.Open(FileDir & FilesInPath).Activate

But I want to combine this with arguments that will open the file as read
only:

Workbooks.Open(FileDir & FilesInPath).Activate , ReadOnly:=True, _
Password:="Metrics"

This line gives me an error "invalid number of arguments".

Is it possible to open as active as read-only?

Thanks -
 
J

Joel

Set NewBk = Workbooks.Open(FileDir & FilesInPath , ReadOnly:=True, _
Password:="Metrics")

NewBk.Activate



It is not recommended to use SELECT or ACTIVATE method it slows down the
code and switches sheets when it is not necessary. It is better to refer to
the book by its set name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top