ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help with Command Bar Button issue ?? (https://www.excelbanter.com/excel-programming/314075-need-help-command-bar-button-issue.html)

Dan Thompson

Need help with Command Bar Button issue ??
 
Hi there,
I must apologize for posting in the excel programing news groups as this vba
code was writen in power point, howver Since it relates to command bar
buttons and forms and stuff I figured that it would be almost the same as
working with command bar buttons and forms in excel. (besides I could not
find a power point "programing" newsgroup)

Anyhow here is my code ....

Sub FloatingButton()
Dim MyBar
Dim MyControl
Set MyBar = CommandBars.Add(Name:="Custom", Position:=msoBarFloating,
MenuBar:=False, Temporary:=True)
Set MyControl = MyBar.Controls.Add(Type:=msoControlButton)
MyControl.Height = 15
MyControl.Width = 150
MyBar.Visible = True
MyControl.Caption = "There Should be Text on my button instead of this tool
tip ???"
End Sub

The problem I am having is that I want a single floating menu bar with one
button on it exactly the same idea as a regular command button on a form.
except for some stupid reason I can't get text to apear on the button itself.
And I would like the button on my floating menu bar to say "Click Me", but
the only text I can get to apear is tool tip text.

Any thoughts would be GREATLY appreciated!

Thanks in advance
Dan.


Bob Phillips[_6_]

Need help with Command Bar Button issue ??
 
Dan,

I think this is what you want

Sub FloatingButton()
Dim MyBar
Dim MyControl
On Error Resume Next
CommandBars("Custom").Delete
On Error GoTo 0
Set MyBar = CommandBars.Add(Name:="Custom", Position:=msoBarFloating, _
MenuBar:=False, Temporary:=True)
Set MyControl = MyBar.Controls.Add(Type:=msoControlButton)
With MyControl
.Caption = "Cick Me"
.Style = msoButtonIconAndCaption
.Height = 15
.Width = 150
End With
MyBar.Visible = True
End Sub

--

HTH

RP

"Dan Thompson" wrote in message
...
Hi there,
I must apologize for posting in the excel programing news groups as this

vba
code was writen in power point, howver Since it relates to command bar
buttons and forms and stuff I figured that it would be almost the same as
working with command bar buttons and forms in excel. (besides I could not
find a power point "programing" newsgroup)

Anyhow here is my code ....

Sub FloatingButton()
Dim MyBar
Dim MyControl
Set MyBar = CommandBars.Add(Name:="Custom", Position:=msoBarFloating,
MenuBar:=False, Temporary:=True)
Set MyControl = MyBar.Controls.Add(Type:=msoControlButton)
MyControl.Height = 15
MyControl.Width = 150
MyBar.Visible = True
MyControl.Caption = "There Should be Text on my button instead of this

tool
tip ???"
End Sub

The problem I am having is that I want a single floating menu bar with one
button on it exactly the same idea as a regular command button on a form.
except for some stupid reason I can't get text to apear on the button

itself.
And I would like the button on my floating menu bar to say "Click Me", but
the only text I can get to apear is tool tip text.

Any thoughts would be GREATLY appreciated!

Thanks in advance
Dan.




Dan Thompson

Need help with Command Bar Button issue ??
 
Thanks for your help Bob I realy appreciate it.

While I was waiting for a reply to my post I solved my issue :)
This is what I ended up using and it works the way I want it.

Sub FloatingCmdBarButton()
Dim MyBar As CommandBar
Dim MyControl As CommandBarButton
Set MyBar = CommandBars.Add(Name:="View Form", Position:=msoBarFloating,
MenuBar:=False, Temporary:=True)
Set MyControl = MyBar.Controls.Add(Type:=msoControlButton)
MyBar.Top = 100
MyBar.Left = 50
MyControl.Caption = "Click Me"
MyControl.Style = msoButtonCaption
MyBar.Visible = True
End Sub

Looks Like your code does the same thing basicly.

cheers!



"Bob Phillips" wrote:

Dan,

I think this is what you want

Sub FloatingButton()
Dim MyBar
Dim MyControl
On Error Resume Next
CommandBars("Custom").Delete
On Error GoTo 0
Set MyBar = CommandBars.Add(Name:="Custom", Position:=msoBarFloating, _
MenuBar:=False, Temporary:=True)
Set MyControl = MyBar.Controls.Add(Type:=msoControlButton)
With MyControl
.Caption = "Cick Me"
.Style = msoButtonIconAndCaption
.Height = 15
.Width = 150
End With
MyBar.Visible = True
End Sub

--

HTH

RP

"Dan Thompson" wrote in message
...
Hi there,
I must apologize for posting in the excel programing news groups as this

vba
code was writen in power point, howver Since it relates to command bar
buttons and forms and stuff I figured that it would be almost the same as
working with command bar buttons and forms in excel. (besides I could not
find a power point "programing" newsgroup)

Anyhow here is my code ....

Sub FloatingButton()
Dim MyBar
Dim MyControl
Set MyBar = CommandBars.Add(Name:="Custom", Position:=msoBarFloating,
MenuBar:=False, Temporary:=True)
Set MyControl = MyBar.Controls.Add(Type:=msoControlButton)
MyControl.Height = 15
MyControl.Width = 150
MyBar.Visible = True
MyControl.Caption = "There Should be Text on my button instead of this

tool
tip ???"
End Sub

The problem I am having is that I want a single floating menu bar with one
button on it exactly the same idea as a regular command button on a form.
except for some stupid reason I can't get text to apear on the button

itself.
And I would like the button on my floating menu bar to say "Click Me", but
the only text I can get to apear is tool tip text.

Any thoughts would be GREATLY appreciated!

Thanks in advance
Dan.





Bob Phillips[_6_]

Need help with Command Bar Button issue ??
 
Yes it does, the main difference is I try and delete the toolbar before
(re)creating it. Safety measure<vbg

--

HTH

RP

"Dan Thompson" wrote in message
...
Thanks for your help Bob I realy appreciate it.

While I was waiting for a reply to my post I solved my issue :)
This is what I ended up using and it works the way I want it.

Sub FloatingCmdBarButton()
Dim MyBar As CommandBar
Dim MyControl As CommandBarButton
Set MyBar = CommandBars.Add(Name:="View Form", Position:=msoBarFloating,
MenuBar:=False, Temporary:=True)
Set MyControl = MyBar.Controls.Add(Type:=msoControlButton)
MyBar.Top = 100
MyBar.Left = 50
MyControl.Caption = "Click Me"
MyControl.Style = msoButtonCaption
MyBar.Visible = True
End Sub

Looks Like your code does the same thing basicly.

cheers!



"Bob Phillips" wrote:

Dan,

I think this is what you want

Sub FloatingButton()
Dim MyBar
Dim MyControl
On Error Resume Next
CommandBars("Custom").Delete
On Error GoTo 0
Set MyBar = CommandBars.Add(Name:="Custom", Position:=msoBarFloating, _
MenuBar:=False, Temporary:=True)
Set MyControl = MyBar.Controls.Add(Type:=msoControlButton)
With MyControl
.Caption = "Cick Me"
.Style = msoButtonIconAndCaption
.Height = 15
.Width = 150
End With
MyBar.Visible = True
End Sub

--

HTH

RP

"Dan Thompson" wrote in message
...
Hi there,
I must apologize for posting in the excel programing news groups as

this
vba
code was writen in power point, howver Since it relates to command bar
buttons and forms and stuff I figured that it would be almost the same

as
working with command bar buttons and forms in excel. (besides I could

not
find a power point "programing" newsgroup)

Anyhow here is my code ....

Sub FloatingButton()
Dim MyBar
Dim MyControl
Set MyBar = CommandBars.Add(Name:="Custom", Position:=msoBarFloating,
MenuBar:=False, Temporary:=True)
Set MyControl = MyBar.Controls.Add(Type:=msoControlButton)
MyControl.Height = 15
MyControl.Width = 150
MyBar.Visible = True
MyControl.Caption = "There Should be Text on my button instead of this

tool
tip ???"
End Sub

The problem I am having is that I want a single floating menu bar with

one
button on it exactly the same idea as a regular command button on a

form.
except for some stupid reason I can't get text to apear on the button

itself.
And I would like the button on my floating menu bar to say "Click Me",

but
the only text I can get to apear is tool tip text.

Any thoughts would be GREATLY appreciated!

Thanks in advance
Dan.








All times are GMT +1. The time now is 08:40 AM.

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