ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Command Button from Control Toolbox (https://www.excelbanter.com/excel-programming/366040-command-button-control-toolbox.html)

Jim May

Command Button from Control Toolbox
 
Can I (somehow) have a command button which is stationary (at a given
position - on Workbook open) and remains Visible and available as I
activate to review different Worksheets? (a "floater" button)..
Thanks in Advance,


lcoreyl[_28_]

Command Button from Control Toolbox
 

YOU CAN MAKE A SEPARATE TOOLBAR FOR EXCEL, WHICH CAN FLOAT OR YOU CAN
ATTACH TO THE OTHER TOOLBARS AT TOP. YOU CAN MAKE IT VISIBLE UPON
OPENING, AND THEN HIDE IT BEFORE CLOSING. THE FOLLOWING WILL CREATE
THIS TOOLBAR WITH TWO BUTTONS THAT LINK TO A MACRO

private sub workbook_open
goto skp
error1:
Call ButtonInstall
skp:
on error goto error1
Application.CommandBars("mybuttons").Visible = True
on error goto 0
end sub

private sub workbook_close
Application.CommandBars("mybuttons").Visible = false
end sub

sub ButtonInstall
Dim NewToolbar As Object
Dim NewButton As Object
Set NewToolbar = Application.CommandBars.Add(Name:="mybuttons",
temporary:=False)
NewToolbar.Visible = True
Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton,
ID:=2950)
With NewButton
..FaceId = 583
..OnAction = "Name of Macro1 here"
..Caption = "Macro1 description here"
End With
Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton,
ID:=2950)
With NewButton
..FaceId = 45
..OnAction = "Name of Macro2 here"
..Caption = "Macro2 description here"
End With
End Sub


--
lcoreyl
------------------------------------------------------------------------
lcoreyl's Profile: http://www.excelforum.com/member.php...fo&userid=2042
View this thread: http://www.excelforum.com/showthread...hreadid=557584


Jim May

Command Button from Control Toolbox
 
Thanks lcorey1;
Much appreciated


"lcoreyl" wrote
in message :

YOU CAN MAKE A SEPARATE TOOLBAR FOR EXCEL, WHICH CAN FLOAT OR YOU CAN
ATTACH TO THE OTHER TOOLBARS AT TOP. YOU CAN MAKE IT VISIBLE UPON
OPENING, AND THEN HIDE IT BEFORE CLOSING. THE FOLLOWING WILL CREATE
THIS TOOLBAR WITH TWO BUTTONS THAT LINK TO A MACRO

private sub workbook_open
goto skp
error1:
Call ButtonInstall
skp:
on error goto error1
Application.CommandBars("mybuttons").Visible = True
on error goto 0
end sub

private sub workbook_close
Application.CommandBars("mybuttons").Visible = false
end sub

sub ButtonInstall
Dim NewToolbar As Object
Dim NewButton As Object
Set NewToolbar = Application.CommandBars.Add(Name:="mybuttons",
temporary:=False)
NewToolbar.Visible = True
Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton,
ID:=2950)
With NewButton
.FaceId = 583
.OnAction = "Name of Macro1 here"
.Caption = "Macro1 description here"
End With
Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton,
ID:=2950)
With NewButton
.FaceId = 45
.OnAction = "Name of Macro2 here"
.Caption = "Macro2 description here"
End With
End Sub


--
lcoreyl
------------------------------------------------------------------------
lcoreyl's Profile: http://www.excelforum.com/member.php...fo&userid=2042
View this thread: http://www.excelforum.com/showthread...hreadid=557584




All times are GMT +1. The time now is 07:34 PM.

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