W
WLMPilot
I have posted this before and I am still having problems. I have researched
myself and cannot come up with anything.
I have a macro that will create 26 commandbuttons on the active sheet. I
get one button created with caption "CommandButton4". I also get Run-time
Error 424: Object required.
I cannot figure it out. The "Activesheet" line matches everything I have
researched.
Any help is greatly appreciated!!!
Private Sub CommandButton2_Click()
Dim h, w, t, l As Long 'h=height, w=width, t=top, l=left
Dim k As Integer
h = 21
w = 91.5
l = 50
t = 92
For k = 1 To 26
ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Left:=l,
Top:=t, Width:=w, Height:=h).Select
OLEObject.Caption = "Button " & k
OLEObject.Name = "Week " & k
t = t + 38
If k = 7 Or k = 14 Or k = 20 Then
l = l + 145
t = 92
End If
Next k
End Sub
The code is suppose to create 26 buttons equal in size and space them,
aligning then equally apart vertically and horizontally.
Much appreciation for anyone helping with this!!!!
Les
myself and cannot come up with anything.
I have a macro that will create 26 commandbuttons on the active sheet. I
get one button created with caption "CommandButton4". I also get Run-time
Error 424: Object required.
I cannot figure it out. The "Activesheet" line matches everything I have
researched.
Any help is greatly appreciated!!!
Private Sub CommandButton2_Click()
Dim h, w, t, l As Long 'h=height, w=width, t=top, l=left
Dim k As Integer
h = 21
w = 91.5
l = 50
t = 92
For k = 1 To 26
ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Left:=l,
Top:=t, Width:=w, Height:=h).Select
OLEObject.Caption = "Button " & k
OLEObject.Name = "Week " & k
t = t + 38
If k = 7 Or k = 14 Or k = 20 Then
l = l + 145
t = 92
End If
Next k
End Sub
The code is suppose to create 26 buttons equal in size and space them,
aligning then equally apart vertically and horizontally.
Much appreciation for anyone helping with this!!!!
Les