View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robin Hammond[_2_] Robin Hammond[_2_] is offline
external usenet poster
 
Posts: 575
Default 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