PC Review


Reply
Thread Tools Rate Thread

Add control to menubar

 
 
Zone
Guest
Posts: n/a
 
      31st Mar 2007
I want to add a control to Excel's standard menubar to show some
text. The control will not do anything other than show its text.
TIA, James

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      1st Apr 2007

with application.commandbars("Worksheet Menu Bar")
with .controls.add(name:="myButton",temporary:=True)
.caption = "some text
end with
end with

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Zone" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I want to add a control to Excel's standard menubar to show some
> text. The control will not do anything other than show its text.
> TIA, James
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      1st Apr 2007
Correction.

With Application.CommandBars("Worksheet Menu Bar")
With .Controls.Add(Type:=msoControlButton, temporary:=True)
.Caption = "some text"
.Style = msoButtonCaption
End With
End With

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Bob Phillips" <(E-Mail Removed)> wrote in message
news:ej1Hv1%(E-Mail Removed)...
>
> with application.commandbars("Worksheet Menu Bar")
> with .controls.add(name:="myButton",temporary:=True)
> .caption = "some text
> end with
> end with
>
> --
> ---
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my
> addy)
>
>
>
> "Zone" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I want to add a control to Excel's standard menubar to show some
>> text. The control will not do anything other than show its text.
>> TIA, James
>>

>
>



 
Reply With Quote
 
Helmut Weber
Guest
Posts: n/a
 
      1st Apr 2007
Hi Bob

perfect.

But how to add a control button with "some text"
to a commandbar other then menu bar?

Setting the caption results in nothing for:

Sub x()
With Application.CommandBars("standard")
.Controls.Add Type:=msoControlButton
.Controls(.Controls.Count).Caption = "xxx"
End With
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"




 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      1st Apr 2007
Don't forget to change the style:

..Style = msoButtonCaption

Option Explicit
Sub x()

Dim myCtrl As CommandBarControl

With Application.CommandBars("standard")
Set myCtrl = .Controls.Add(Type:=msoControlButton, temporary:=True)
With myCtrl
.Caption = "xxx"
.Style = msoButtonCaption
.OnAction = "'" & ThisWorkbook.Name & "'!macro1"
End With

Set myCtrl = .Controls.Add(Type:=msoControlButton, temporary:=True)
With myCtrl
.Caption = "yyy"
.Style = msoButtonCaption
.OnAction = "'" & ThisWorkbook.Name & "'!macro2"
End With
End With
End Sub
Sub macro1()
MsgBox "macro1"
End Sub
Sub macro2()
MsgBox "macro2"
End Sub

Helmut Weber wrote:
>
> Hi Bob
>
> perfect.
>
> But how to add a control button with "some text"
> to a commandbar other then menu bar?
>
> Setting the caption results in nothing for:
>
> Sub x()
> With Application.CommandBars("standard")
> .Controls.Add Type:=msoControlButton
> .Controls(.Controls.Count).Caption = "xxx"
> End With
> End Sub
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"


--

Dave Peterson
 
Reply With Quote
 
Zone
Guest
Posts: n/a
 
      1st Apr 2007
Thank you, Bob. Works perfect! James

On Mar 31, 7:45�pm, "Bob Phillips" <bob....@somewhere.com> wrote:
> Correction.
>
> * * With Application.CommandBars("Worksheet Menu Bar")
> * * * * With .Controls.Add(Type:=msoControlButton, temporary:=True)
> * * * * * * .Caption = "some text"
> * * * * * * .Style = msoButtonCaption
> * * * * End With
> * * End With
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Bob Phillips" <bob....@somewhere.com> wrote in message
>
> news:ej1Hv1%(E-Mail Removed)...
>
>
>
>
>
> > * *with application.commandbars("Worksheet Menu Bar")
> > * * * *with .controls.add(name:="myButton",temporary:=True)
> > * * * * * *.caption = "some text
> > * * * *end with
> > * *end with

>
> > --
> > ---
> > HTH

>
> > Bob

>
> > (there's no email, no snail mail, but somewhere should be gmail in my
> > addy)

>
> > "Zone" <jkend69...@aol.com> wrote in message
> >news:(E-Mail Removed)...
> >>I want to add a control to Excel's standard menubar to show some
> >> text. *The control will not do anything other than show its text.
> >> TIA, James- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
get parameter from menubar control Richard Microsoft Access 0 30th Jul 2009 10:44 AM
Re: Code for setting Forms to open with custom tool bar, menubar and control custom short Rick Brandt Microsoft Access 0 5th Feb 2006 01:06 PM
Menubar Control =?Utf-8?B?aXRzcm9iaGFpbmVz?= Microsoft Excel Programming 1 20th Jan 2006 12:30 PM
Problem adding a control to menubar Stefan Uhlemann Microsoft Outlook VBA Programming 0 30th Mar 2004 03:09 PM
How to control menubar Kate Microsoft Access VBA Modules 2 23rd Mar 2004 07:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:39 PM.