Creation and property manipulation of Control Checkbox using VB

B

BRG

I have created a tool that allows the user to import specific data from a
related spreadsheet. This data gets pasted into the next open row in a table
in the open spreadsheet.

I'm looking for a method to create a new control checkbox in the rightmost
column whenever a new row is created in the table. I'd also like to
manipulate the properties of the button, for instance link the button to the
cell beneath, set the size of the button to be the same as the linked cell,
change the button's colour and caption etc. Any hints would be greatly
appreciated
 
J

Jim Thomlinson

Here is some quick and dirty code to get you started...

Dim ctl As OLEObject

Set ctl = activesheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1")

ctl.TopLeftCell = ActiveCell
ctl.Object.Caption = "Tada"
 
B

BRG

Hey Jim,

Thanks for the tip, that was what I was looking for. Just a quick question
out of curiosity, the checkboxes that are created with this code are
different than the checkboxes that I create using the controls toolbar, for
instance I can't right click on these checkboxes to access their properties.
In the code you sent the class type is "Forms.CheckBox.1". Is this actually
equivalent to a Forms checkbox? And if so how do you create a "Controls"
checkbox?

Thanks,
 

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