Captions and Check Boxes [Error]

ronnockoch

New Member
Joined
Jun 9, 2014
Messages
13
Hello all,

Quick question.
I'm writting a VBA code for a project i'm working on and I've exaughsted my google searching trying to figure this out.

The problem I'm having is this.

Code:
ActiveSheet.OLEObjects.Add ClassType:="Forms.CheckBox.1", _    Link:=False, _
    DisplayAsIcon:=False, _
    Left:=Range("A1").Left, _
    Top:=Cells(1, 1).Top, _
    Width:=108, _
    Height:=19.5, _
    Caption:=""

This code is throwing an error for me when running and it's on the Caption:="" line. The rest of the code runs flawlessly.
The error I get is: Run Time error 448: Named Argument not Found

From my quick research on this problem, Im starting to believe that I can't change caption from my side and it would have to be done manually.


Alternatively, a code snippet which would create check boxes only (no caption by default) would also be nice :)

Let me know if you have any other questions I can try and answer
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try

Code:
Sub test()
Dim cb As Object
Set cb = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Link:=False, _
    DisplayAsIcon:=False, _
    Left:=Range("A1").Left, _
    Top:=Cells(1, 1).Top, _
    Width:=108, _
    Height:=19.5)
cb.Object.Caption = vbNullString
End Sub
 
Upvote 0
Try

Code:
Sub test()
Dim cb As Object
Set cb = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Link:=False, _
    DisplayAsIcon:=False, _
    Left:=Range("A1").Left, _
    Top:=Cells(1, 1).Top, _
    Width:=108, _
    Height:=19.5)
cb.Object.Caption = vbNullString
End Sub

VoG,

that worked perfectly.
I went one step further and tested my next question (value) and it worked as well.

Thanks

Could you give me a quick explanation as to why the caption property can't be changed like above?

Thanks again,
 
Upvote 0
only that OLE Objects are a bit weird and some of the properties apply to the OLEObject itself and some to the OLEObject.Object.
 
Upvote 0

Forum statistics

Threads
1,216,181
Messages
6,129,355
Members
449,506
Latest member
nomvula

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top