ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Restricting Menus (https://www.excelbanter.com/excel-programming/281695-restricting-menus.html)

R. Todd Miller[_2_]

Restricting Menus
 
I can't figure this out so perhaps someone here has some ideas...
The first two lines of code work and grey-out File-New and Edit-Cut.
The third line should grey-ouy Insert-Rows but it yields a Runtime
error '91': Object variable or With block variable not set. Any ideas
(Excel 97). Thanks in advance.

Sub RestrictMenus()
Application.CommandBars("File").FindControl(Id:=18 ).Enabled = False
Application.CommandBars("Edit").FindControl(Id:=21 ).Enabled = False
Application.CommandBars("Insert").FindControl(Id:= 296).Enabled = False
End Sub

Dick Kusleika[_3_]

Restricting Menus
 
R

To be honest, I didn't know you could get to the File and Edit menus in that
fashion. Here's another way:

Application.CommandBars("Worksheet Menu
Bar").Controls("Insert").Controls("Rows").Enabled = False

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"R. Todd Miller" wrote in message
om...
I can't figure this out so perhaps someone here has some ideas...
The first two lines of code work and grey-out File-New and Edit-Cut.
The third line should grey-ouy Insert-Rows but it yields a Runtime
error '91': Object variable or With block variable not set. Any ideas
(Excel 97). Thanks in advance.

Sub RestrictMenus()
Application.CommandBars("File").FindControl(Id:=18 ).Enabled = False
Application.CommandBars("Edit").FindControl(Id:=21 ).Enabled = False
Application.CommandBars("Insert").FindControl(Id:= 296).Enabled = False
End Sub





All times are GMT +1. The time now is 02:12 PM.

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