ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Proteting against a button press (https://www.excelbanter.com/excel-programming/280508-proteting-against-button-press.html)

John Baker

Proteting against a button press
 
Hi:

I have a spreadsheet containing buttons which activate macros. I want to protect one
sheet in the workbook so that no one can write on it, and no one can activate the buttons
without a password. When I protect sheet, I find that while the cells are protected the
button can be activated.

Can someone tell me how to set the BUTTONS so that they cant be pressed and activate the
macros.

Thanks a lot

JOhn Baker

Tom Ogilvy

Proteting against a button press
 
You could use the sheet activate event to disable the buttons or hide them
(check the protection status of the sheet)


You could have each button's macro check the state of the sheet and jump out
without doing anything if it is protected.

If you need more help, specify where the buttons are from; control toolbox
toolbar or forms toolbar.

--
Regards,
Tom Ogilvy



"John Baker" wrote in message
...
Hi:

I have a spreadsheet containing buttons which activate macros. I want to

protect one
sheet in the workbook so that no one can write on it, and no one can

activate the buttons
without a password. When I protect sheet, I find that while the cells are

protected the
button can be activated.

Can someone tell me how to set the BUTTONS so that they cant be pressed

and activate the
macros.

Thanks a lot

JOhn Baker




John Baker

Proteting against a button press
 
Tom:

They are from the control toolbox. If i were to use the macro to check the state of the
sheets protection, how would I go about it? Its a viable alternative, since I only have
three buttons on that sheet, and they link to everything I want to protect.

Regards

John Baker

"Tom Ogilvy" wrote:

You could use the sheet activate event to disable the buttons or hide them
(check the protection status of the sheet)


You could have each button's macro check the state of the sheet and jump out
without doing anything if it is protected.

If you need more help, specify where the buttons are from; control toolbox
toolbar or forms toolbar.



Dave Peterson[_3_]

Proteting against a button press
 
How about:

Option Explicit
Private Sub CommandButton1_Click()

If Me.ProtectContents _
Or Me.ProtectDrawingObjects _
Or Me.ProtectScenarios Then
MsgBox "can't run on this protected worksheet"
Exit Sub
End If

'your code here
MsgBox "hi"

End Sub




John Baker wrote:

Tom:

They are from the control toolbox. If i were to use the macro to check the state of the
sheets protection, how would I go about it? Its a viable alternative, since I only have
three buttons on that sheet, and they link to everything I want to protect.

Regards

John Baker

"Tom Ogilvy" wrote:

You could use the sheet activate event to disable the buttons or hide them
(check the protection status of the sheet)


You could have each button's macro check the state of the sheet and jump out
without doing anything if it is protected.

If you need more help, specify where the buttons are from; control toolbox
toolbar or forms toolbar.


--

Dave Peterson



All times are GMT +1. The time now is 08:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com