Macro to check if a Workbook is read only?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I have the following macro that opens up a document and runs another macro,
I use it to update a document that lots of people share by creating the changes I want in a macro then running this code and the document is updated without having to hold everyone up.
this all works fine and I wish to carry on doing things this way, except if the document is being used I just get a read only copy then a save as request at the end.

I'd like the macro to stop if the document is read only and record the word "Read Only" in sheet "Data" cell G15.
if the document is not read only then run my macro.

please help if you can

thanks

Tony

MY Current Macro:

Code:
Sub OpenLondon()
StoreName = "London"

Workbooks.Open ("S:\" & StoreName & "\New Documents Folder\" & "New" & StoreName & ".xlsm")

 Workbooks("New" & StoreName & ".xlsm").Activate
 
Call TonySecret124

Workbooks("New" & StoreName & ".xlsm").Close savechanges:=True

End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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