Disable/Password Protect Macro in Read-Only

jaclynresendez

New Member
Joined
Jan 20, 2009
Messages
19
Hello All,

I couldn't find an existing thread. Does anyone know if there is a way to either password protect or disable a macro (in this case a toggle button) if the spreadsheet is opened as read-only? I have the spreadsheet automatically open as read-only to users who do not have the password for modify access. There is one toggle button I do not want the user to be able to use if it is read-only. Is that possible?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
you could try a workbook open event (see below). The below code will be placed in the "ThisWorkbook" module:

Code:
Private Sub Workbook_Open()
 
    If ThisWorkbook.ReadOnly Then
     
        Sheets("Sheet1").ToggleButton1.Enabled = False
 
    End If

End Sub
 
Upvote 0
make sure the sheet references in the code match the name of your sheet. Currently it is set to "Sheet1" so you'll have to change this if the name of your sheet the toggle button is on has a different name. Also, check the togglebutton name which, currently, the code is set to "ToggleButton1" which may or may not be the name of your toggle button. Finally, make sure this code is pasted in the "ThisWorkbook" module.
 
Upvote 0

Forum statistics

Threads
1,215,409
Messages
6,124,743
Members
449,186
Latest member
HBryant

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