You don't need such an elaborate code to create your control. Here's a
cleaner version...

Sub indrajit()

    With Application
        On Error Resume Next
        .CommandBars("Sam Mathai Chacko").Delete
        With .CommandBars.Add("Sam Mathai Chacko", 4)
            .Visible = .Enabled
            With .Controls.Add(1)
                .Style = 2
                .Caption = "My ToolBar"
                .OnAction = "YourMacro"
                .Visible = .Enabled
            End With
        End With
    End With

End Sub

Regards,
Sam Mathai Chacko

On Tue, Jan 17, 2012 at 7:25 PM, Rajan_Verma <rajanverma1...@gmail.com>wrote:

> Hi****
>
> Hope it will help you ****
>
> ** **
>
> http://www.ozgrid.com/VBA/custom-menus.htm****
>
> ** **
>
> Regards****
>
> Rajan. Verma****
>
> ** **
>
> ** **
>
> *From:* excel-macros@googlegroups.com [mailto:
> excel-macros@googlegroups.com] *On Behalf Of *INDRAJIT SAHA
> *Sent:* Jan/Sun/2012 02:49
> *To:* excel-macros@googlegroups.com
> *Subject:* $$Excel-Macros$$ Want to see the caption in the button in the
> toolbar****
>
> ** **
>
> Hi All,****
>
> ** **
>
> I am unable to get the caption in the button in the toolbar.****
>
> What is happening that if I keep the cursor on the button then only the
> caption is showing.****
>
> But I want that the caption words visible in the button.****
>
> Hope my question is pretty clear!****
>
> I am pasting a sample code. It will be great if you can modify it.****
>
> Private Sub workbook_open()****
>
> Call indrajit****
>
> End Sub****
>
> ** **
>
> Sub indrajit()****
>
> Dim tbar As CommandBar, c1 As CommandBarControl****
>
> On Error Resume Next****
>
> CommandBars("indrajit").Delete****
>
> Set tbar = Application.CommandBars.Add(Name:="indrajit",
> Position:=msoBarFloating)****
>
> With tbar****
>
>     .Enabled = True****
>
>     .Visible = True****
>
> End With****
>
> Set c1 = tbar.Controls.Add(Type:=msoControlButton)****
>
> With c1****
>
>     .Caption = "want to see this words visible in the toolbar"****
>
>     .OnAction = "i"****
>
>     .Enabled = True****
>
>     .Visible = True****
>
> End With****
>
> End Sub****
>
> ** **
>
> Sub i()****
>
> Range("A1") = "outpot got after clicking the button in the indrajit
> toolbar"****
>
> End Sub****
>
> ** **
>
> Warm Regards,****
>
> Indrajit Saha****
>
> Mob: 08884375868****
>
> indrajitsah...@gmail.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****
>
> --
> 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
>



-- 
Sam Mathai Chacko

-- 
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