how do you open a file read-only?

M

Mark Seger

Being pretty new to macro writing, my standard approach to everything is
to record bits and pieces of what I want to do in mini-macros and then
use that code to build up a more general one.

When I record a macro while opening a file read-only, nothing gets
captured that indicated it's read-only. Furthermore, if I execute the
macro it opens the file as writable.

Does this mean you can't write a macro to open a file read-only OR is
there a bug in excel in that it's not capturing that fact in 'record macro'?

-mark
 
D

dominicb

Good afternoon Mark

Try this

Workbooks.Open Filename:= "C:\TestFile.xls", ReadOnly:=True

The ReadOnly function does seem to be documented, but not to a great
extent. But it works.

HTH

DominicB
 

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