Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Add control to menubar

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Add control to menubar


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" wrote in message
oups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Add control to menubar

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" wrote in message
...

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" wrote in message
oups.com...
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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default Add control to menubar

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"




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Add control to menubar

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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Add control to menubar

Thank you, Bob. Works perfect! James

On Mar 31, 7:45�pm, "Bob Phillips" 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" wrote in message

...





* *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" wrote in message
roups.com...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
enable menubar Shane Excel Programming 1 April 20th 06 05:39 AM
Menubar Control itsrobhaines Excel Programming 1 January 20th 06 12:30 PM
Icon for Menubar Jaggu Excel Programming 2 November 5th 04 01:28 PM
excel menubar majikman[_26_] Excel Programming 3 May 24th 04 04:13 PM
menubar buttons don't appear Janet[_5_] Excel Programming 1 January 30th 04 07:32 PM


All times are GMT +1. The time now is 09:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"