Macro for closing and reopening a workbook read-only

Remster

New Member
Joined
Apr 16, 2009
Messages
22
I have a pair of macros that together close and reopen a workbook when the user clicks on a button labelled 'Refresh'. The reason for the macros is that any one of multiple users may have the workbook open for editing while the others have it open read-only, and those who have it open read-only will want to refresh it periodically to make sure they're viewing the most up-to-date version.

Now, here's the hitch. If I have the workbook open read-only and refresh it while no-one else has it open for editing, it doesn't reopen read-only (it reopens for editing). But I don't want it to reopen for editing (I want it to reopen read-only). Is there anything I can add to the macros to make the workbook reopen read-only, or is there a different pair of macros I can use? Here's what I have at the moment:

Macro 1
Sub CloseMe()
'
Application.OnTime Now, "OpenMe"
ThisWorkbook.Close SaveChanges:=False
'
End Sub

Macro 2
Sub OpenMe()
'
End Sub
 
So long as it is only open once as read-write, you should have no problem. I tested my solution here with a colleague and it worked like a dream.

One thing though, assuming that the read-only users would not read-write, you should really only give them that option on opening the file, otherwise they could be in it read-write when another user needs to update it.
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
So long as it is only open once as read-write, you should have no problem. I tested my solution here with a colleague and it worked like a dream.
It isn't saved as a shared workbook, so that shouldn't be a problem (I'm assuming that by 'only open once as read-write' you mean 'open as read-write by only one user at a time').<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
One thing though, assuming that the read-only users would not read-write, you should really only give them that option on opening the file, otherwise they could be in it read-write when another user needs to update it.
The Web page from which users will be opening the file has read-only as its default option – they have to make a bit more effort to open it for editing – so that shouldn't be a problem either.<o:p></o:p>
<o:p></o:p>
Many thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,707
Members
448,981
Latest member
recon11bucks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top