View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Enable/Disable Menu Items

Hi Andrew,

If you create your menu like this:

Sub CreateMyMenu()
With Application.CommandBars("Worksheet Menu Bar"). _
Controls.Add(Type:=msoControlPopup, Temporary:=False)
.Caption = "My Menu"
With .Controls.Add(Type:=msoControlButton)
.Caption = "Item 1"
.Tag = "Item 1"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Item 2"
.Tag = "Item 2"
End With
End With
End Sub

You should be able to use a routine like this to enable/disable a given
control via its Tag property:

Sub ToggleMenuItem(rsTag As String, rbEnabled As Boolean)
Application.CommandBars.FindControl(Tag:=rsTag). _
Enabled = rbEnabled
End Sub


--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Andrew Kennard wrote:
Hi all

I've created my own custom menu and added items to it.

eg My Menu, Item1, Item 2 etc

I would like to be able to change the enabled property of each item
inside certain subs. But no matter what I try I can't seem to 'get a
hold' on the ITEM to change it's state ? I have sucessfully changed
the state of the MENU to enabled true/false but not indiviual items.

I've done lots of googling but still have no luck with simlar 'delete'
examples that I presume should work. The main problem sees to be even
adding Tag properties I cannot use FindControls to find an ITEM

TIA

Andrew


 
ExcelBanter Database Error
Database Error Database error
The ExcelBanter database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.excelbanter.com home page, then try to open another page.
  • Click the Back button to try another link.
The www.excelbanter.com forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.