ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Form Button Security (https://www.excelbanter.com/excel-programming/367323-form-button-security.html)

Paul Black

Form Button Security
 
Hi everyone,

What I would like to do is to stop somebody right clicking the Form
Button and assigning another Macro to it. I have Passworded the VBA
Code.
Any help will be greatly appreciated.

Thanks in advance.
All the Best.
Paul


Norman Jones

Form Button Security
 
Hi Paul,

Try:

'=============
Private Sub Workbook_Activate()
Application.CommandBars("Excel Control"). _
FindControl(ID:=859).Enabled = False
End Sub

'--------------

Private Sub Workbook_Deactivate()
Application.CommandBars("Excel Control"). _
FindControl(ID:=859).Enabled = True
End Sub

'--------------

Private Sub Workbook_Open()
Application.CommandBars("Excel Control"). _
FindControl(ID:=859).Enabled = False
End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman



Paul Black

Form Button Security
 
Thanks for the reply Norman, I will certainly give it a go.

All the Best.
Paul

Norman Jones wrote:
Hi Paul,

Try:

'=============
Private Sub Workbook_Activate()
Application.CommandBars("Excel Control"). _
FindControl(ID:=859).Enabled = False
End Sub

'--------------

Private Sub Workbook_Deactivate()
Application.CommandBars("Excel Control"). _
FindControl(ID:=859).Enabled = True
End Sub

'--------------

Private Sub Workbook_Open()
Application.CommandBars("Excel Control"). _
FindControl(ID:=859).Enabled = False
End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman




All times are GMT +1. The time now is 05:52 PM.

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