ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding Macro Button on Standard Toolbar (https://www.excelbanter.com/excel-programming/307377-re-adding-macro-button-standard-toolbar.html)

sebastienm

Adding Macro Button on Standard Toolbar
 
Maybe try to set the Style property to
msoButtonIcon
or
msoButtonCaption

regards,
Seb

"Jeff Harbin" wrote:

I'm trying to add a custom button on the normal menu bar that will run a
macro when clicked and I've almost got it with a couple of quirks.

1. The code below adds the button and it runs the correct code but the
button has not label. My intention is that the second line of code
(MenuItem.Caption = "Start New Roll") is what should appear on the menu
button. Instead the button has no caption and unless you knew it was there
you wouldn't see it. Instead of the label being "Start New Roll", the "Start
New Roll" text comes up as if it were a ToolTip. I have had some success of
identifying the macro button by putting an icon in it but I'd rather not.
I've been adding the icon by specifying an integer value in the ID variable
of the .Add method.

///code start/////
Dim MenuItem as Object

Set MenuItem = Application.CommandBars("Worksheet Menu
Bar").Controls.Add(msoControlButton, , , 13, True)

MenuItem.Caption = "Start New Roll"

MenuItem.OnAction = "DisplayMessage"
////code end//////


Jeff Harbin[_2_]

Adding Macro Button on Standard Toolbar
 
How would I do that. The help on this topic isn't very useful.




"sebastienm" wrote in message
...
Maybe try to set the Style property to
msoButtonIcon
or
msoButtonCaption

regards,
Seb

"Jeff Harbin" wrote:

I'm trying to add a custom button on the normal menu bar that will run a
macro when clicked and I've almost got it with a couple of quirks.

1. The code below adds the button and it runs the correct code but the
button has not label. My intention is that the second line of code
(MenuItem.Caption = "Start New Roll") is what should appear on the menu
button. Instead the button has no caption and unless you knew it was

there
you wouldn't see it. Instead of the label being "Start New Roll", the

"Start
New Roll" text comes up as if it were a ToolTip. I have had some

success of
identifying the macro button by putting an icon in it but I'd rather

not.
I've been adding the icon by specifying an integer value in the ID

variable
of the .Add method.

///code start/////
Dim MenuItem as Object

Set MenuItem = Application.CommandBars("Worksheet Menu
Bar").Controls.Add(msoControlButton, , , 13, True)

MenuItem.Caption = "Start New Roll"

MenuItem.OnAction = "DisplayMessage"
////code end//////




sebastienm

Adding Macro Button on Standard Toolbar
 
Just tried it, it should be the msoButtonCaption. In your code, add:
MenuItem.Style = msoButtonCaption

Regards,
Sebastien

"Jeff Harbin" wrote:

How would I do that. The help on this topic isn't very useful.




"sebastienm" wrote in message
...
Maybe try to set the Style property to
msoButtonIcon
or
msoButtonCaption

regards,
Seb

"Jeff Harbin" wrote:

I'm trying to add a custom button on the normal menu bar that will run a
macro when clicked and I've almost got it with a couple of quirks.

1. The code below adds the button and it runs the correct code but the
button has not label. My intention is that the second line of code
(MenuItem.Caption = "Start New Roll") is what should appear on the menu
button. Instead the button has no caption and unless you knew it was

there
you wouldn't see it. Instead of the label being "Start New Roll", the

"Start
New Roll" text comes up as if it were a ToolTip. I have had some

success of
identifying the macro button by putting an icon in it but I'd rather

not.
I've been adding the icon by specifying an integer value in the ID

variable
of the .Add method.

///code start/////
Dim MenuItem as Object

Set MenuItem = Application.CommandBars("Worksheet Menu
Bar").Controls.Add(msoControlButton, , , 13, True)

MenuItem.Caption = "Start New Roll"

MenuItem.OnAction = "DisplayMessage"
////code end//////





Jeff Harbin[_2_]

Adding Macro Button on Standard Toolbar
 
Thanks,

I've got the Workbook at work. I'll try it first thing in the morning.

Jeff



"sebastienm" wrote in message
...
Just tried it, it should be the msoButtonCaption. In your code, add:
MenuItem.Style = msoButtonCaption

Regards,
Sebastien

"Jeff Harbin" wrote:

How would I do that. The help on this topic isn't very useful.




"sebastienm" wrote in message
...
Maybe try to set the Style property to
msoButtonIcon
or
msoButtonCaption

regards,
Seb

"Jeff Harbin" wrote:

I'm trying to add a custom button on the normal menu bar that will

run a
macro when clicked and I've almost got it with a couple of quirks.

1. The code below adds the button and it runs the correct code but

the
button has not label. My intention is that the second line of code
(MenuItem.Caption = "Start New Roll") is what should appear on the

menu
button. Instead the button has no caption and unless you knew it

was
there
you wouldn't see it. Instead of the label being "Start New Roll",

the
"Start
New Roll" text comes up as if it were a ToolTip. I have had some

success of
identifying the macro button by putting an icon in it but I'd rather

not.
I've been adding the icon by specifying an integer value in the ID

variable
of the .Add method.

///code start/////
Dim MenuItem as Object

Set MenuItem = Application.CommandBars("Worksheet Menu
Bar").Controls.Add(msoControlButton, , , 13, True)

MenuItem.Caption = "Start New Roll"

MenuItem.OnAction = "DisplayMessage"
////code end//////








All times are GMT +1. The time now is 01:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com