Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Questions, criticisms and comments welcome - there must be an easier way!
'--------------------------------------------------------------------------------------- ' Procedure : hasAtLeastOneControlEnabled ' Purpose : Determines if the passed command bar has at least one control enabled. If the ' bar has even one control enabled then the bar should be enabled; if no ' controls enabled then the bar needs to be disabled. ' Inputs : CommandBar the command bar of interest ' Outputs : Boolean True if one control is enabled (the first one found is enough). ' Precon(s) : The controls have already been enabled/disabled based on context. ' DateTime : 2/1/2006 ' Author : EBF '--------------------------------------------------------------------------------------- ' Private Function hasAtLeastOneControlEnabled(aParentBar As Office.CommandBar) As Boolean On Error Resume Next Dim bResult As Boolean Dim ctl As Office.CommandBarControl For Each ctl In aParentBar.Controls If TypeOf ctl Is CommandBarPopup Then bResult = hasAtLeastOneControlEnabled(ctl) <====this doesn't recurse here Else If ctl.Enabled Then bResult = True hasAtLeastOneControlEnabled = bResult Exit Function End If End If Next ctl End Function |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You cannot declare the argument as type commandbar if you are going to pass
commandbars, popups and buttons through it. Try declaring it as a generic object. -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Eric" wrote in message ink.net... Questions, criticisms and comments welcome - there must be an easier way! '--------------------------------------------------------------------------- ------------ ' Procedure : hasAtLeastOneControlEnabled ' Purpose : Determines if the passed command bar has at least one control enabled. If the ' bar has even one control enabled then the bar should be enabled; if no ' controls enabled then the bar needs to be disabled. ' Inputs : CommandBar the command bar of interest ' Outputs : Boolean True if one control is enabled (the first one found is enough). ' Precon(s) : The controls have already been enabled/disabled based on context. ' DateTime : 2/1/2006 ' Author : EBF '--------------------------------------------------------------------------- ------------ ' Private Function hasAtLeastOneControlEnabled(aParentBar As Office.CommandBar) As Boolean On Error Resume Next Dim bResult As Boolean Dim ctl As Office.CommandBarControl For Each ctl In aParentBar.Controls If TypeOf ctl Is CommandBarPopup Then bResult = hasAtLeastOneControlEnabled(ctl) <====this doesn't recurse here Else If ctl.Enabled Then bResult = True hasAtLeastOneControlEnabled = bResult Exit Function End If End If Next ctl End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
sub routine | Excel Discussion (Misc queries) | |||
VBA routine (101) | Excel Programming | |||
Using (what goes in here) for sub routine | Excel Programming | |||
SUB ROUTINE | Excel Programming | |||
Need VBA Routine | Excel Programming |