A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Just comment out the "If .ReadOnly Then Exit Sub" line. Now the routine will work for all files.
Eric
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I like to review other spreadsheets people work in as read-only. Is there a VBA which allows me to “refresh” the file by closing it & then opening again in ready only?
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Just comment out the "If .ReadOnly Then Exit Sub" line. Now the routine will work for all files.
Eric
The VBA only seems to work if I have a file only in writing mode. Its really if I have a file open as read only. I'd to close & re-open it again as read-only giving it a "refresh" in case someone made edits in the file.
Add the code below to your PERSONAL.XLSB or an AddIn.
Andreas.
Sub ReOpenReadOnly()
Dim Fullname As String
With ActiveWorkbook
'New file?
If .Path = "" Then Exit Sub
'Already readonly?
If .ReadOnly Then Exit Sub
'Save the path\file name of the current file
Fullname = .Fullname
'Close it, ignore changes
.Close False
End With
'ReOpen readonly
Workbooks.Open Fullname, ReadOnly:=True
End Sub