R
robert.hatcher
I'm trying to add a control to a worksheet and then modify its
parameters. To learn how to do this I have the following code:
Option Explicit
Public Sub InsertChkBx1()
'insert checkbox at cell B2
ActiveSheet.OLEObjects.Add classtype:="Forms.CheckBox.1", _
Left:=48.75, Top:=13.5, Height:=11.25, Width:=46.5
End Sub
Public Sub renameChkBx()
Sheet1.CheckBox1.Caption = "testbx"
End Sub
Running Sub InsertChkBx1 and then renameChkBx works fine.
The next step is run them from one piece of code...
Public Sub InsertChkBx1()
'insert checkbox at cell B2
ActiveSheet.OLEObjects.Add classtype:="Forms.CheckBox.1", _
Left:=48.75, Top:=13.5, Height:=11.25, Width:=46.5
Sheet1.CheckBox1.Caption = "testbx"
End Sub
But I get a compile error highlighting "checkBox1" - Method or
data member not found. Probably because there is no checkbox yet. I
decided to keep them separate and just call the second procedure from
the first...
Public Sub InsertChkBx1()
'insert checkbox at cell B2
ActiveSheet.OLEObjects.Add classtype:="Forms.CheckBox.1", _
Left:=48.75, Top:=13.5, Height:=11.25, Width:=46.5
renameChkBx
End Sub
Public Sub renameChkBx()
Sheet1.CheckBox1.Caption = "testbx"
End Sub
But I get the same error just down in the second procedure.
Any help will be greatly appreciated
Robert
parameters. To learn how to do this I have the following code:
Option Explicit
Public Sub InsertChkBx1()
'insert checkbox at cell B2
ActiveSheet.OLEObjects.Add classtype:="Forms.CheckBox.1", _
Left:=48.75, Top:=13.5, Height:=11.25, Width:=46.5
End Sub
Public Sub renameChkBx()
Sheet1.CheckBox1.Caption = "testbx"
End Sub
Running Sub InsertChkBx1 and then renameChkBx works fine.
The next step is run them from one piece of code...
Public Sub InsertChkBx1()
'insert checkbox at cell B2
ActiveSheet.OLEObjects.Add classtype:="Forms.CheckBox.1", _
Left:=48.75, Top:=13.5, Height:=11.25, Width:=46.5
Sheet1.CheckBox1.Caption = "testbx"
End Sub
But I get a compile error highlighting "checkBox1" - Method or
data member not found. Probably because there is no checkbox yet. I
decided to keep them separate and just call the second procedure from
the first...
Public Sub InsertChkBx1()
'insert checkbox at cell B2
ActiveSheet.OLEObjects.Add classtype:="Forms.CheckBox.1", _
Left:=48.75, Top:=13.5, Height:=11.25, Width:=46.5
renameChkBx
End Sub
Public Sub renameChkBx()
Sheet1.CheckBox1.Caption = "testbx"
End Sub
But I get the same error just down in the second procedure.
Any help will be greatly appreciated
Robert