Eliminate Read-Write Message

M

Magnivy

Hello,

I have a macro that opens each file in a directory, copies some data into
another file, and then closes each file. Sometimes, after I ran the macro,
messages pop up asking whether I want to open one of more of the files in the
directory in Read-Write mode. I think this is because my macro opened some
files that were in use by others (and so it opened them in a Read-Only mode)
and were subsequently closed.

Is there a way to eliminate this message?

Thanks very much for your help!
Magnivy
 
D

Dave Peterson

Maybe you can incorporate something like this into your loop:

Dim wkbk As Workbook

Set wkbk = Workbooks.Open(Filename:="C:\my documents\excel\book3.xls")

If wkbk.ReadOnly Then
MsgBox wkbk.FullName & " is readonly--closing"
wkbk.Close savechanges:=False
Else
'do the work??
end if
 

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