programming checkbox properties

M

mark

Hey.

I have a range of cells for which I would like to put a
checkbox in the center of each cell.

This works for creating the checkbox:

ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1",
Left:=ActiveCell.Left + ActiveCell.Width / 2 - 7,
Top:=ActiveCell.Top + ActiveCell.Height / 2 - 7,
Width:=14, Height _
:=14).Select


What I need now is to link the checkbox to the cell that
it was just placed in.

I know it's using the .LinkedCell property, but I haven't
found what vb code will do it.

??
Thanks.
 
T

Tom Ogilvy

ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1",
Left:=ActiveCell.Left + ActiveCell.Width / 2 - 7,
Top:=ActiveCell.Top + ActiveCell.Height / 2 - 7,
Width:=14, Height _
:=14).Select
Selection.LinkedCell = ActiveCell.Address(external:=True)
 
M

mark

Selection.LinkedCell = ActiveCell.Address(external:=True)


Thanks, Tom.

I should have thought of that.

I think I did try Selection.LinkedCell , but I made the
mistake of giving it the cell as a range, instead of the
cell address as string text.

But it wasn't giving me a type error, it was giving me a
property not supported error, and I didn't happen to think
about needing to use the address.

Thanks for you help.

Mark
 
M

mark

Selection.LinkedCell = ActiveCell.Address(external:=True)



as a followup, can you tell me why when the checkbox is
selected, adding the code line:

Selection.Caption = ""

produces Run Time Error 38 Object doesn't support this
property or method
 
T

Tom Ogilvy

Try selection.Object.Caption

activesheet.OleObjects(1).Select
? typename(selection)
OLEObject
? selection.Object.Caption
CheckBox1
 

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

Top