+ Reply to Thread
Results 1 to 2 of 2

routine won't recurse

  1. #1
    Eric
    Guest

    routine won't recurse

    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. #2
    Bob Phillips
    Guest

    Re: routine won't recurse

    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" <efingerhut@earthlink.net> wrote in message
    news:ErfEf.9520$1n4.1233@newsread2.news.pas.earthlink.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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1