Dear Divakar,

Please use below code to add custom button and Tab
Option Explicit

'Add a new menu to Worksheet Menu Bar
Public Sub AddCustomMenu()
    Dim cbr As CommandBar
    Dim ctlMenu As CommandBarControl

    'Add new menu control
    Set cbr = Application.CommandBars("Worksheet Menu Bar")
    Set ctlMenu = cbr.Controls.Add(Type:=msoControlPopup)

    'Add controls to new menu control
    With ctlMenu
        .Caption = "Custom"

        With .Controls.Add(Type:=msoControlButton)
            .Caption = "Show Data Form"
            .OnAction = "ShowDataForm"
        End With

        With .Controls.Add(Type:=msoControlButton)
            .Caption = "Print Data List"
            .OnAction = "PrintDataList"
        End With

        With .Controls.Add(Type:=msoControlButton)
            .Caption = "Sort Names Ascending"
            .BeginGroup = True
            .OnAction = "SortList"
            .Parameter = "Asc"
        End With

        With .Controls.Add(Type:=msoControlButton)
            .Caption = "Sort Names Descending"
            .OnAction = "SortList"
            .Parameter = "Dsc"
        End With

        With .Controls.Add(Type:=msoControlButton)
            .Caption = "Show Products"
            .OnAction = "'ShowProduct ""Apple"", 3, 4'"
        End With

    End With

End Sub

'Delete Custom menu
Public Sub RemoveCustomMenu()
    Dim cbr As CommandBar

    On Error Resume Next

    Set cbr = CommandBars("WorkSheet Menu Bar")
    cbr.Controls("Custom").Delete

End Sub


On Wed, Mar 28, 2012 at 9:22 PM, Divaker Pandey <divake...@gmail.com> wrote:

>
> Hi Expert,
>
> I want to add our own custom button and Tab in Excel 2007 name in place
> add-in.
>
> Divaker
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>



-- 
Thanks & regards,
Noorain Ansari
 ** <http://excelmacroworld.blogspot.com/>*http://noorainansari.com/*
*http://excelmacroworld.blogspot.com/*<http://excelmacroworld.blogspot.com/>

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to