Making commandbutton11.visible = false when the book opens as read only

0 Agios

Well-known Member
Joined
Feb 22, 2004
Messages
570
Office Version
  1. 365
in a vba form i need the saving command button to be invisible when the book opens as read only, i tried a number of things but they don't work, please help.

here is what i am trying to use but it don't work

If WB.ReadOnly = True Then
CommandButton11.Visible = False
Exit Sub
End If
 

Excel Facts

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

where did you put the code?

VBA Code:
Private Sub UserForm_Initialize()
If ThisWorkbook.ReadOnly = True Then
  CommandButton11.Visible = False
  Exit Sub
End If
End Sub
Code behind the UserForm works for me.

Ciao,
Holger
 
Upvote 0
Hi rhombus4,

maybe I misunderstand in a vba form when thinking of a Userform but for that case I´d stick with the event mentioned (I rarely change the status of a workbook so that would be the best place to put that command for me).

And if it should be in the Workbook_Open there should be a classification as sheetname or name of userform in order to get it to work (although I doubt it to work if the userform isn´t loaded by then).

Ciao,
Holger
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,390
Members
448,957
Latest member
Hat4Life

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