LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Hal Hal is offline
external usenet poster
 
Posts: 36
Default Menu item deletion

I have been working with Steven Roman's, 'Writing Excel Macros with VBA' 2nd
Edition. The code below adds the Custom popup menu to the worksheet menu. The
code does not contain a Temporary:=True statment when the control was added
to the menu. Now I alway have a Custom popup menu when I launch Excel.

Before I add the Temporary:=True to the Controls.Add line of code I want to
delete the existing Custom menu. Can I get some help on how I can ID the
current Custom menu item? No Tag was set and I don't know how to determine
the controls ID so I can use it for the purpose of deleting it.

Thanks in advance

Hal

Sub CreatePopup()
' Example 12-5 pg 149

Dim cbpop As CommandBarControl
Dim cbctl As CommandBarControl
Dim cbsub As CommandBarControl

' Create a popup control on the main menu bar
Set cbpop = Application.CommandBars("Worksheet Menu Bar"). _
Controls.Add(Type:=msoControlPopup)
cbpop.Caption = "&Custom"
cbpop.Visible = True
' Add a menu item
Set cbctl = cbpop.Controls.Add(Type:=msoControlButton)
cbctl.Visible = True
' Next is required for caption
cbctl.Style = msoButtonCaption
cbctl.Caption = "MenuItem&1"
' Action to perform
cbctl.OnAction = "ExampleMacro1"
' Add a popup for a submenu
Set cbsub = cbpop.Controls.Add(Type:=msoControlPopup)
cbsub.Visible = True
cbsub.Caption = "&SubMenuItem1"
' Add a menu item to the submenu
Set cbctl = cbsub.Controls.Add(Type:=msoControlButton)
cbctl.Visible = True
' Next is required for caption
cbctl.Style = msoButtonCaption
cbctl.Caption = "SubMenuItem&2"
' Action to perform
cbctl.OnAction = "ExampleMacro2"

End Sub
 
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
Menu-Item and worksheet deletion questions Hari Prasadh[_2_] Excel Programming 3 June 28th 05 07:41 AM
Menu Item name Christopher Sequeira Excel Programming 4 June 13th 05 08:58 PM
Menu items added with menu item editor in older versions Michael Hoffmann Excel Discussion (Misc queries) 2 January 7th 05 01:40 PM
Adding a menu item right click menu when clicking on a single. Andoni[_28_] Excel Programming 0 September 2nd 04 10:23 PM
New menu bar item Juan[_3_] Excel Programming 3 May 15th 04 10:43 AM


All times are GMT +1. The time now is 03:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"