+ Reply to Thread
Results 1 to 3 of 3

How to delete Custom VBA Menu

  1. #1
    Jeff
    Guest

    How to delete Custom VBA Menu

    I have created a VBA menu using the following code and now want to remove the
    menu but can't. Any ideas on how to remove the menu and to make it go away
    when I close the particular file it is attached to?

    Jeff

    Sub AddNewMenu()

    Dim oCB As CommandBar
    Set oCB = Application.CommandBars("Worksheet Menu Bar")
    Dim newMenu As CommandBarControl

    Set newMenu = oCB.Controls.Add(Type:=10)
    With newMenu
    .Caption = "Transit Manager"
    .Enabled = True
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "Start . . ."
    .FaceId = 39
    .OnAction = "Start_New_Process"
    End With
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "Import LE's"
    .FaceId = 938
    .OnAction = "macro2"
    End With
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "Import Actuals"
    .FaceId = 988
    .OnAction = "macro3"
    End With
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "Print Reduced"
    .FaceId = 707
    .OnAction = "macro2"
    End With
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "Button5"
    .FaceId = 29
    .OnAction = "macro1"
    End With
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "Finish . . ."
    .FaceId = 41
    .OnAction = "macro2"
    End With
    End With

    End Sub

  2. #2
    Bob Phillips
    Guest

    Re: How to delete Custom VBA Menu

    Application.CommandBars("Worksheet Menu Bar").Controls("Tranist
    Manager").Delete


    --
    HTH

    Bob Phillips

    "Jeff" <[email protected]> wrote in message
    news:[email protected]...
    > I have created a VBA menu using the following code and now want to remove

    the
    > menu but can't. Any ideas on how to remove the menu and to make it go away
    > when I close the particular file it is attached to?
    >
    > Jeff
    >
    > Sub AddNewMenu()
    >
    > Dim oCB As CommandBar
    > Set oCB = Application.CommandBars("Worksheet Menu Bar")
    > Dim newMenu As CommandBarControl
    >
    > Set newMenu = oCB.Controls.Add(Type:=10)
    > With newMenu
    > .Caption = "Transit Manager"
    > .Enabled = True
    > With .Controls.Add(Type:=msoControlButton)
    > .Caption = "Start . . ."
    > .FaceId = 39
    > .OnAction = "Start_New_Process"
    > End With
    > With .Controls.Add(Type:=msoControlButton)
    > .Caption = "Import LE's"
    > .FaceId = 938
    > .OnAction = "macro2"
    > End With
    > With .Controls.Add(Type:=msoControlButton)
    > .Caption = "Import Actuals"
    > .FaceId = 988
    > .OnAction = "macro3"
    > End With
    > With .Controls.Add(Type:=msoControlButton)
    > .Caption = "Print Reduced"
    > .FaceId = 707
    > .OnAction = "macro2"
    > End With
    > With .Controls.Add(Type:=msoControlButton)
    > .Caption = "Button5"
    > .FaceId = 29
    > .OnAction = "macro1"
    > End With
    > With .Controls.Add(Type:=msoControlButton)
    > .Caption = "Finish . . ."
    > .FaceId = 41
    > .OnAction = "macro2"
    > End With
    > End With
    >
    > End Sub




  3. #3
    Jeff
    Guest

    Re: How to delete Custom VBA Menu

    Thanks Bob, worked like a charm

    JEff

    "Bob Phillips" wrote:

    > Application.CommandBars("Worksheet Menu Bar").Controls("Tranist
    > Manager").Delete
    >
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Jeff" <[email protected]> wrote in message
    > news:[email protected]...
    > > I have created a VBA menu using the following code and now want to remove

    > the
    > > menu but can't. Any ideas on how to remove the menu and to make it go away
    > > when I close the particular file it is attached to?
    > >
    > > Jeff
    > >
    > > Sub AddNewMenu()
    > >
    > > Dim oCB As CommandBar
    > > Set oCB = Application.CommandBars("Worksheet Menu Bar")
    > > Dim newMenu As CommandBarControl
    > >
    > > Set newMenu = oCB.Controls.Add(Type:=10)
    > > With newMenu
    > > .Caption = "Transit Manager"
    > > .Enabled = True
    > > With .Controls.Add(Type:=msoControlButton)
    > > .Caption = "Start . . ."
    > > .FaceId = 39
    > > .OnAction = "Start_New_Process"
    > > End With
    > > With .Controls.Add(Type:=msoControlButton)
    > > .Caption = "Import LE's"
    > > .FaceId = 938
    > > .OnAction = "macro2"
    > > End With
    > > With .Controls.Add(Type:=msoControlButton)
    > > .Caption = "Import Actuals"
    > > .FaceId = 988
    > > .OnAction = "macro3"
    > > End With
    > > With .Controls.Add(Type:=msoControlButton)
    > > .Caption = "Print Reduced"
    > > .FaceId = 707
    > > .OnAction = "macro2"
    > > End With
    > > With .Controls.Add(Type:=msoControlButton)
    > > .Caption = "Button5"
    > > .FaceId = 29
    > > .OnAction = "macro1"
    > > End With
    > > With .Controls.Add(Type:=msoControlButton)
    > > .Caption = "Finish . . ."
    > > .FaceId = 41
    > > .OnAction = "macro2"
    > > End With
    > > End With
    > >
    > > End Sub

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1