how do i programmatically insert a button on a worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top