By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,458 Members | 1,215 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,458 IT Pros & Developers. It's quick & easy.

Make Menu Items Not Visible

P: n/a
I notice the Tag property for menu items. Is there a way to assign say a 1 to
the Tag property of certain menu items and then make those menu items not
visible programatically?

Thanks!

Heather
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try something like this (watch the line wrap):

Dim cbc As Object

For Each cbc In Application.CommandBars("My
Menu").Controls("File").CommandBar.Controls
If cbc.Tag = "1" Then
cbc.Visible = False
Else
cbc.Visible = True
End If
Next cbc

That will check each control on the File menu of a custom menu. You
could set a reference to the Microsoft Office library then declare cbc
as a CommandBarControl or use late binding (declaring cbc As Object)
like the example above. HTH

Rick Collard
www.msc-lims.com
On Tue, 11 Nov 2003 22:09:15 GMT, "Heather"
<ha******@cseducationalsystems.org> wrote:
I notice the Tag property for menu items. Is there a way to assign say a 1 to
the Tag property of certain menu items and then make those menu items not
visible programatically?

Thanks!

Heather


Nov 12 '05 #2

P: n/a
Rick,

Thank you very much for the response!

How would I cycle through multiple menu items where each menu item may have
multiple controls. My custom menu consists of Projects, Subcontractors,
Suppliers and Setup with a mix of menu items under them. The menu items could be
a menu with a sublist of menu items under it or just a single action menu item.

Thanks for your help!

Heather

PS Thanks for your response to my Parameter question too!
"Rick Collard" <no****@nospam.nospam> wrote in message
news:3f***************@news.west.earthlink.net...
Try something like this (watch the line wrap):

Dim cbc As Object

For Each cbc In Application.CommandBars("My
Menu").Controls("File").CommandBar.Controls
If cbc.Tag = "1" Then
cbc.Visible = False
Else
cbc.Visible = True
End If
Next cbc

That will check each control on the File menu of a custom menu. You
could set a reference to the Microsoft Office library then declare cbc
as a CommandBarControl or use late binding (declaring cbc As Object)
like the example above. HTH

Rick Collard
www.msc-lims.com
On Tue, 11 Nov 2003 22:09:15 GMT, "Heather"
<ha******@cseducationalsystems.org> wrote:
I notice the Tag property for menu items. Is there a way to assign say a 1 to
the Tag property of certain menu items and then make those menu items not
visible programatically?

Thanks!

Heather

Nov 12 '05 #3

P: n/a
Your best bet will be to use recursion. Here's an example that lists
the visible entries on the A2K2 Menu Bar by calling procedure
ListCommandBarControls recursively.

Public Sub ListCommandBarControls(cbp As CommandBarPopup, sSpaces As
String)

Dim cbc As CommandBarControl

For Each cbc In cbp.Controls
If cbc.Visible Then
Debug.Print sSpaces & cbc.Caption
If cbc.Type = msoControlPopup Then
ListCommandBarControls cbc.Control, sSpaces & Space(3)
End If
End If
Next cbc
End Sub

Public Sub ListMenuBar()

Dim cbp As CommandBarPopup

Debug.Print "Menu Bar"
For Each cbp In Application.CommandBars("Menu Bar").Controls
Debug.Print Space(3) & cbp.Caption
ListCommandBarControls cbp, Space(6)
Next cbp

End Sub

Just run procedure ListMenuBar in the immediate window and you will
get a list of all visible items on the Menu Bar and all submenus. HTH

Rick Collard
www.msc-lims.com

On Wed, 12 Nov 2003 02:18:15 GMT, "Heather"
<ha******@cseducationalsystems.org> wrote:
Rick,

Thank you very much for the response!

How would I cycle through multiple menu items where each menu item may have
multiple controls. My custom menu consists of Projects, Subcontractors,
Suppliers and Setup with a mix of menu items under them. The menu items could be
a menu with a sublist of menu items under it or just a single action menu item.

Thanks for your help!

Heather

PS Thanks for your response to my Parameter question too!


Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.