Check Box Macro

G

Guest

Hi, I am trying to write a macro that includes putting 2 checkboxes onto a
sheet, then rewriting the text in them and changing the background colour.
so far all i have been able to do is set the position and size but cannot
set the text or colour.

any help would be much appreciated

thankyou

Patrick
 
I

Ian

I just created a macro by recording whilst inserting a checkbox, then
changing the text and background colour. Results below:

Sub InsertCheckbox()
ActiveSheet.CheckBoxes.Add(250.5, 42.75, 72, 72).Select
ActiveSheet.Shapes("Check Box 1").Select
Selection.Characters.Text = "New text"
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 53
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoFalse
End Sub

You say you've already created the checkboxes, but you should be able to
extract the basis of what you need from this macro.

Hope this helps.
 
R

Rick Rothstein \(MVP - VB\)

I think Ian's code refers to a check box added from the Forms Toolbar. Try
something like this to change the text and color...

CheckBox1.Caption = "New Text Goes Here"
CheckBox1.BackColor = vbRed
CheckBox1.ForeColor = vbWhite

using your control's names, of course.

Rick
 
G

Guest

here is my code:


ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Link:=False, _
DisplayAsIcon:=False, Left:=600.75, Top:=108.75, Width:=195.75,
Height _
:=51).Select
CheckBox1.Caption = "New Text Goes Here"
CheckBox1.BackColor = vbRed
CheckBox1.ForeColor = vbWhite

i get the error "object required"

have tried lots of different ways round it but nothing seems to work!
driving me crazy!!
 

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

Similar Threads


Top