I have a macro that automatically closes out of all open workbooks; however, I want it to close without saving the read only documents. Right now it closes out of everything, but a pop up appears asking if the user wants to save the read only worksheet.
I don't want that pop-up to appear. I want it to just exit out and save all spreadsheets except the read only ones WITHOUT asking.
Here is the current code:
I don't want that pop-up to appear. I want it to just exit out and save all spreadsheets except the read only ones WITHOUT asking.
Here is the current code:
Code:
Sub CloseOpenWorkbooks()
Dim Wkb As Workbook
With Application
.ScreenUpdating = False
For Each Wkb In Workbooks
With Wkb
' If the book is read-only
' don't save but close
If Not Wkb.ReadOnly Then
.Save
End If
' save this workbook, but don't close it
' so the macro still runs
If .Name <> ThisWorkbook.Name Then
.Close
End If
End With
Next Wkb
.ScreenUpdating = True
.Quit
End With
End Sub