Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Enable/Disable Menu Items

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Enable/Disable Menu Items

Commandbars("Custom 2").Controls(3).Controls(2).Enabled = False

worked for me.

--
Regards,
Tom Ogilvy

"Andrew Kennard" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Enable/Disable Menu Items

Thanks for that

Now got it working ...... the problem (very strange) seems to be if the Tag
value is "PB" it does not work ??? ie FindControl doesn't find it ?

TIA

Andrew

"Tom Ogilvy" wrote in message
...
Commandbars("Custom 2").Controls(3).Controls(2).Enabled = False

worked for me.

--
Regards,
Tom Ogilvy

"Andrew Kennard" wrote in message
...
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






Reply
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
How to enable items on Excel draw menu bar. JD Excel Discussion (Misc queries) 3 May 10th 08 01:51 AM
Is is possible to disable certain menu items Buster Excel Programming 1 November 19th 04 08:11 AM
Disable menu items with VBA jst_se Excel Programming 1 July 22nd 04 08:25 PM
Menu Items and Disable/Enable in Excel 2003 [email protected] Excel Programming 1 February 6th 04 08:14 PM
HELP - How do I disable Excels menu items so others can't use Marcello do Guzman Excel Programming 2 December 20th 03 02:14 PM


All times are GMT +1. The time now is 08:34 PM.

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"