View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Eliminate Read-Write Message

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

Magnivy wrote:

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


--

Dave Peterson