ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Floating Command Button (https://www.excelbanter.com/excel-programming/410539-floating-command-button.html)

Don Lowe

Floating Command Button
 
How do I create a floating command button?

Gary''s Student

Floating Command Button
 
Create a custom toolbar and place it on the worksheet directly rather than at
tool area at the top of the window.

Then place any required buttons in the new toolbar. It will "float" as you
scroll up or down.
--
Gary''s Student - gsnu200784


"Don Lowe" wrote:

How do I create a floating command button?


Jim Rech

Floating Command Button
 
Here's an example:

Sub MakeFloatingCommandbar()
On Error Resume Next
CommandBars("MyCB").Delete
On Error GoTo 0
CommandBars.Add "MyCB", msoBarFloating, , True
With CommandBars("MyCB")
With .Controls.Add(msoControlButton)
.Caption = "Btn1"
.FaceId = 80
.OnAction = "Macro1"
End With
With .Controls.Add(msoControlButton)
.Caption = "Btn2"
.FaceId = 81
.OnAction = "Macro2"
End With
.Visible = True
End With
End Sub


--
Jim
"Don Lowe" wrote in message
...
| How do I create a floating command button?



Don Lowe

Floating Command Button
 
Jim,

I have taken your example and tried to create a Floating Command Bar (Shown
Below). I am guessing that I have done something wrong, because I get
nothing. Please Help!!!

Sub CommandButton97_Click()
'
' CommandButton97_Click Macro
' Macro recorded 5/6/2008 by g141183
'

Application.Goto Reference:=Worksheets("Master Report").Range("A1"),
Scroll:=True

End Sub

-----------------------------------------------------------------------------------------
Sub Scroll31Right()
ActiveWindow.SmallScroll Toright:=31
End Sub

-----------------------------------------------------------------------------------------
Sub Scroll31Left()
ActiveWindow.SmallScroll Toleft:=31
End Sub

-----------------------------------------------------------------------------------------
Sub MakeFloatingCommandbar()
On Error Resume Next
CommandBars("MyCB").Delete
On Error GoTo 0
CommandBars.Add "MyCB", msoBarFloating, , True
With CommandBars("MyCB")
With .Controls.Add(msoControlButton)
.Caption = "Right"
.FaceId = 80
.OnAction = "Scroll31Right()"
End With
With .Controls.Add(msoControlButton)
.Caption = "Left"
.FaceId = 81
.OnAction = "Scroll31Left()"
End With
With .Controls.Add(msoControlButton)
.Caption = "Main"
.FaceId = 83
.OnAction = "CommandButton97_Click()"
End With
.Visible = True
End With
End Sub



All times are GMT +1. The time now is 02:27 PM.

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