ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Eliminate Read-Write Message (https://www.excelbanter.com/excel-programming/390549-eliminate-read-write-message.html)

Magnivy

Eliminate Read-Write Message
 
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

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


All times are GMT +1. The time now is 09:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com