+ Reply to Thread
Results 1 to 2 of 2

how do I add more toolbar options to my right click options

  1. #1
    Rosie
    Guest

    how do I add more toolbar options to my right click options

    I am trying to add more toolbar options to my right click options

  2. #2
    Ron de Bruin
    Guest

    Re: how do I add more toolbar options to my right click options

    Hi Rosie

    Maybe thiis
    Or do you want to add buid in controls ?
    See example below this example

    This example will add 3 controls to the Cell menu that run your own macro's.

    Change this two lines :

    onaction_names = Array("macro1", "macro2", "macro3")
    caption_names = Array("caption 1", "caption 2", "caption 3")


    Sub Add_Controls()
    Dim i As Long
    Dim onaction_names As Variant
    Dim caption_names As Variant
    onaction_names = Array("macro1", "macro2", "macro3")
    caption_names = Array("caption 1", "caption 2", "caption 3")
    With Application.CommandBars("Cell")
    For i = LBound(onaction_names) To UBound(onaction_names)
    With .Controls.Add(Type:=msoControlButton)
    .OnAction = ThisWorkbook.Name & "!" & onaction_names(i)
    .Caption = caption_names(i)
    End With
    Next i
    End With
    End Sub

    Sub Delete_Controls()
    Dim i As Long
    Dim caption_names As Variant
    caption_names = Array("caption 1", "caption 2", "caption 3")
    With Application.CommandBars("Cell")
    For i = LBound(caption_names) To UBound(caption_names)
    On Error Resume Next
    .Controls(caption_names(i)).Delete
    On Error GoTo 0
    Next i
    End With
    End Sub



    This example will add the Save and Print control to the cell menu.

    Sub Add_Cell_Menu_Items()
    Dim IDnum As Variant
    Dim N As Integer

    IDnum = Array("3", "4")

    For N = LBound(IDnum) To UBound(IDnum)
    On Error Resume Next
    Application.CommandBars("Cell").Controls.Add _
    Type:=msoControlButton, ID:=IDnum(N), before:=1
    On Error GoTo 0
    Next N
    End Sub

    Sub Delete_Cell_Menu_Items()
    Dim IDnum As Variant
    Dim N As Integer

    IDnum = Array("3", "4")

    For N = LBound(IDnum) To UBound(IDnum)
    On Error Resume Next
    Application.CommandBars("Cell").FindControl(ID:=IDnum(N)).Delete
    On Error GoTo 0
    Next N
    End Sub


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl



    "Rosie" <[email protected]> wrote in message news:[email protected]...
    >I am trying to add more toolbar options to my right click options




+ 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