LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default trying to enable top level command bars by context

I'm using the Parameter property of the controls to enable/disable them along
the lines of a concept from "Prof. Excel Dev.". Since the command bar parent
has no such property, and I want to keep the code reusable, after I've set
all the controls I'm trying the code below, which is documented better then
it works (it doesn't call itself recursively)

Questions, criticisms and comments welcome - there must be an easier way to
do this...

'---------------------------------------------------------------------------------------
' 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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Bars KneeDown2Up Excel Discussion (Misc queries) 4 January 16th 07 05:43 PM
context for the command bar Eric[_27_] Excel Programming 1 February 2nd 06 12:40 PM
Command Bars Neil Hopkinson[_2_] Excel Programming 3 August 19th 05 09:53 AM
Enable a new dimention: sub-level of split cells yarp Excel Discussion (Misc queries) 3 August 8th 05 04:11 PM
command bars Geo Siggy[_16_] Excel Programming 6 April 22nd 04 10:50 AM


All times are GMT +1. The time now is 11:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"