FindControl ?!?

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hi

The FindControl returns the first element or Nothing, if no control was
found. But I want to find all controls, that are available. How to do?

Tom
 
Tom,

It isn't clear what you are trying to do, but Office 2000 and
later supports the FindControls method that will return a
collection of controls.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Chip

I need to find all sorting buttons (IDs 210, 211, 1209, 6687) that are in
the toolsbars of Excel. In a second step the enabled-property of all these
controls must be set to false. The tool should work for Excel 97, 2000, XP &
2003.

Tom
 
Hi Tom

This will work in 97-2003

Sub menuItem_EnabledFalse()
Dim a As Integer
On Error Resume Next
For a = 1 To Application.CommandBars.Count
For Each ctl In CommandBars(a).Controls
Application.CommandBars(a).FindControl(Id:=210, Recursive:=True).Enabled = False
Next ctl
Next a
End Sub

Sub menuItem_EnabledTrue()
Dim a As Integer
On Error Resume Next
For a = 1 To Application.CommandBars.Count
For Each ctl In CommandBars(a).Controls
Application.CommandBars(a).FindControl(Id:=210, Recursive:=True).Enabled = True
Next ctl
Next a
 
Back
Top