Can you change the background color of a check box?

J

Jolibeanz

I am creating a protected form that will be using a number of check boxes.
We'd like to use a 3 color coding system - green (good); yellow (needs
attention soon) and red (needs immediate attention).

I've tried coloring the cell the check block resides in, but it does not
give the visual impact we had hoped for. Using 3 colored squares gives the
appearance but not the convenience of a check block. Any suggestions?
 
J

Jolibeanz

Not exactly what I was looking for, but definately food for thought. For my
application I would need to create 3 macros (one for each color) and apply
the appropriate one to each box. Correct? Also, siince I'm a relative macro
newb, in the macro where it says "Password:=sPassword" - I would insert the
password for that document in place of the "sPassword"?
 
G

Graham Mayor

No - you only need the one macro, but it needs fine tuning to ensure the
correct colour is selected.

Let's assume that the three fields are Check1 (Red), Check2 (Orange), and
Check3 (Green), then the following will colour those check boxes
accordingly. If you have more than one set of check boxes, say Check4 (Red),
Check5 (Orange), and Check6 (Green) then add the box names to the case
statements eg

Case "Check1", "Check4"
Etc
Case "Check2", "Check5"
Etc
Case "Check3", "Check6"
Etc

The password for the form goes between the quotes in the line
sPassword = ""

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Private mstrFF As String
Sub EmphasiseCheckedBox()
Dim oFld As FormFields
Dim sCount As Integer
Dim bProtected As Boolean
Dim sPassword As String
sPassword = "" 'Insert the password (if any), used to protect the form
between the quotes
With GetCurrentFF 'Establish field is current
mstrFF = GetCurrentFF.name
End With
Set oFld = ActiveDocument.FormFields
sCount = oFld(mstrFF).CheckBox.Value 'Get the Checkbox field value
'Check if the document is protected and if so unprotect it
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If
With oFld(mstrFF).Range
If sCount = True Then
Select Case oFld(mstrFF).name
Case "Check1"
.Font.Color = wdColorRed
Case "Check2"
.Font.Color = wdColorOrange
Case "Check3"
.Font.Color = wdColorGreen
End Select
Else
.Font.Color = wdColorAutomatic 'Set the colour of the unchecked
box
End If
End With
'Re-protect the form and apply the password (if any).
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If
End Sub
Private Function GetCurrentFF() As Word.FormField
Dim rngFF As Word.Range
Dim fldFF As Word.FormField
Set rngFF = Selection.Range
rngFF.Expand wdParagraph
For Each fldFF In rngFF.FormFields
Set GetCurrentFF = fldFF
Exit For
Next
End Function


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

I managed to insert an extra signature block :blush:( so with some news readers
you may not see the modified code, which was:

Private mstrFF As String
Sub EmphasiseCheckedBox()
Dim oFld As FormFields
Dim sCount As Integer
Dim bProtected As Boolean
Dim sPassword As String
sPassword = "" 'Insert the password (if any), used to protect the form
between the quotes
With GetCurrentFF 'Establish field is current
mstrFF = GetCurrentFF.name
End With
Set oFld = ActiveDocument.FormFields
sCount = oFld(mstrFF).CheckBox.Value 'Get the Checkbox field value
'Check if the document is protected and if so unprotect it
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If
With oFld(mstrFF).Range
If sCount = True Then
Select Case oFld(mstrFF).name
Case "Check1"
.Font.Color = wdColorRed
Case "Check2"
.Font.Color = wdColorOrange
Case "Check3"
.Font.Color = wdColorGreen
End Select
Else
.Font.Color = wdColorAutomatic 'Set the colour of the unchecked
box
End If
End With
'Re-protect the form and apply the password (if any).
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=sPassword
End If
End Sub
Private Function GetCurrentFF() As Word.FormField
Dim rngFF As Word.Range
Dim fldFF As Word.FormField
Set rngFF = Selection.Range
rngFF.Expand wdParagraph
For Each fldFF In rngFF.FormFields
Set GetCurrentFF = fldFF
Exit For
Next
End Function


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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