Number of items in a menu

  • Thread starter Thread starter Guest
  • Start date Start date
Hi.
Is is possible to retreive the number of item in a custom menubar
Yes.

how

Try:

Public Sub getMenuItemCount()

On Error GoTo ErrHandler

MsgBox "The menu bar has " & countMenuItems("MyCustomMenuBar") & _
" items."

Exit Sub

ErrHandler:

MsgBox "Error in getMenuItemCount( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub


Public Function countMenuItems(sMenuName As String) As Long

On Error GoTo ErrHandler

countMenuItems = Application.CommandBars(sMenuName).Controls.Count

Exit Function

ErrHandler:

MsgBox "Error in countMenuItems( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Function

.. . . where MyCustomMenuBar is the name of the custom menu bar.


HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.

- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Parameter?

If you mean "yourbar", then as Gunny said, it's the name of
the menu bar.

Your questions are extrordinarily terse. It would help us
help you if you provided a little more information about
your situation and what you are trying to accomplish.
 
Ah ha, the dawn breaks. The parameter question is a repeat
of the question in another thread. Please don't do that,
it's not fair for you to expect us to be familiar with all
of your posts. One thread, one question is the general
guidline.

Besides, Gunny had already provided an excellent answer in
the other thread.
 
Sorry, I forgot I had already asked this, the answers have been very helpfull.

Amiga1200

Marshall Barton said:
Ah ha, the dawn breaks. The parameter question is a repeat
of the question in another thread. Please don't do that,
it's not fair for you to expect us to be familiar with all
of your posts. One thread, one question is the general
guidline.

Besides, Gunny had already provided an excellent answer in
the other thread.
--
Marsh
MVP [MS Access]

Thanks, also related, how do I use the parameter value
 
Back
Top