Changing Workbook to "Read Only" on ActiveWorkbook.Close

LSM1604

New Member
Joined
Jan 8, 2010
Messages
49
Hey,

I have a Save & Close Button and I was wondering if it was possible for when I click that button for the Workbook to Save itself as Read Only (Same file name and same directory), then close.

I currently have this...

Code:
ActiveWorkbook.Close SaveChanges:=True

The reason why I would like the file to become Read Only is because I would like the workbook to open as Read Only the next time it is opened.

Thanks,
LSM1604
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,978
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Don't know about the "Read only", but have you considered protecting ALL sheets on close instead, which will do the same thing ?
 

LSM1604

New Member
Joined
Jan 8, 2010
Messages
49
Hi,

Thank you for your reply. All of the sheets are protected. When the workbook is opened, I have a login screen. On the log in screen, there is a choice of "Edit Mode" or "Info Only Mode". I want to limit the number of people in Edit Mode at any one time to 1, so no conflicts can occur (Shared workbook cannot be used). If edit mode is selected then read/write mode is activated and a cell value is changed to "Currently In Use", the workbook then saves.

I ideally need something which either:

1) Saves the workbook as read only.
2) When it opens tells me if someone else already has the workbook open. Then I can use that information and the information from a the aforementioned cell value to see if the person opening the workbook can have write access.

The reason for this is to ensure that the workbook has not been closed incorrectly therefore keeping the saved value of "Currently In Use", which will prevent more than one user in write mode, and will also prevent no one from being able to go into write mode.

Hope that makes sense (it almost confused me!).

Thanks again,
LSM1604
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,978
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Hmm, you're right, I'm a little confused.
In answer to the points
1) Saves the workbook as read only.
My previous post would do that !!
2) When it opens tells me if someone else already has the workbook open. Then I can use that information and the information from a the aforementioned cell value to see if the person opening the workbook can have write access.
Excel does this by default when the workbook is opened by more than one person on a network
How about a workbook beforeclose event macro that either clears or changes the "in use" cell when it saves.
 

Forum statistics

Threads
1,143,638
Messages
5,719,979
Members
422,254
Latest member
sayedsaid

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
Top