ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how do i programmatically insert a button on a worksheet (https://www.excelbanter.com/excel-programming/322190-how-do-i-programmatically-insert-button-worksheet.html)

Qaspec

how do i programmatically insert a button on a worksheet
 
i want to programatically insert a command button into a worksheet that is
not the active worksheet. I dont care about placement, size , just that the
command button is on worksheet "main" and the command button is "emp1".

thanks

Robin Hammond[_2_]

how do i programmatically insert a button on a worksheet
 
Something like this

Sub Test()
InsertButton Workbooks("Book2").Sheets(1), 0, 0, 200, 100, "test", "test",
"test"
End Sub

Sub InsertButton(shName As Worksheet, _
Top As Double, Left As Double, Width As Double, Height As Double, _
Action As String, Caption As String, Name As String)
Dim bInsert As Object

'add the control button
Set bInsert = shName.Buttons.Add(Left, Top, Width, Height)
bInsert.OnAction = Action
bInsert.Characters.Text = Caption
bInsert.Name = Name

End Sub

Robin Hammond
www.enhanceddatasystems.com

"Qaspec" wrote in message
...
i want to programatically insert a command button into a worksheet that is
not the active worksheet. I dont care about placement, size , just that
the
command button is on worksheet "main" and the command button is "emp1".

thanks





All times are GMT +1. The time now is 12:29 AM.

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