problems with FindControl

T

tjb

I'm using the FindControl property to turn off things I
don't want my users to change for but am finding a few
that don't seem to work.

On Ron DeBruin's site (which has some really cool and
useful stuff) he says the FindControl ID for Page Setup
under the File menus is 247 but when I enter the folliwng
code it doesn't turn it off for the workbook like it does
for the other stuff.

Private Sub Workbook_Activate()
Application.CommandBars.FindControl(ID:=247).Enabled =
False
End Sub

Private Sub Workbook_Deactivate()
Application.CommandBars.FindControl(ID:=247).Enabled =
True
End Sub

It works for most other things but not this one. Any
ideas?
 
R

Ron de Bruin

Hi tjb

In this case you must use
For some reasons ? Excel count 10 controls with that number

With the code below you tell Excel which one you want to disable

Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=247, Recursive:=True).Enabled = False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top