View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Robin Hammond Robin Hammond is offline
external usenet poster
 
Posts: 79
Default Creating buttons using VBA

Try this.

Sub AddButton()
Dim btn1 As Object
Set btn1 = ActiveSheet.Buttons.Add(0, 0, 100, 66)
With btn1
.OnAction = "RunSub"
.Characters.Text = "Caption"
.ShapeRange.Top = 0
.Name = "ButtonName"
End With
End Sub


--
Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in


"CT" wrote in message
nk.net...
I am trying to create a button and put it onto a spreadsheet using VBA.

Dim cmdButton As Object
Set cmdButton = CreateObject("Forms.CommandButton.1")
cmdButton.Top = 0

Run time error 438;
Object: doesn't support this property or method

Occurs on cmdButton.Top = 0

I am trying to set the position of the top of the new command button.
Where am I going wrong?

Thanks,
Tim