WORD FORMS

M

Martin D

I need to change the colour of a CELL in a word form depending on the
seletion of a Dropdown form called "Select Level" which provides 4 differing
levels to choose from.
Level 1 = Platinum
Level 2 = Gold
Level 3 = Silver
Level 4 = Bronze
And i Wish to change the colour of cells further down the form to those
colours specified against each level. I believe that I may need touse a macro
to do this, but have never actually used one before and do not even know how
to start (Complete Novice in Macro) so would need instructions of how to
input the macro if anyone is kind enough to provide me with one.

Many thanks in advance
 
G

Graham Mayor

You would need a macro like the following stored in the document template
http://www.gmayor.com/installing_macro.htm
and run on exit from the dropdown form field. The example colours row1
column1 and row3 column 1 in Table 1 with the colours shown

Sub ColorCells()
Dim oFld As FormFields
With ActiveDocument
If .ProtectionType <> wdNoProtection Then
.Unprotect Password:=""
End If
Set oFld = .FormFields
Select Case oFld("SelectLevel").Result
Case Is = "Platinum"
.Tables(1).Cell(1, 1).Range.Shading.BackgroundPatternColor =
wdColorGray15
.Tables(1).Cell(3, 1).Range.Shading.BackgroundPatternColor =
wdColorGray15
Case Is = "Gold"
.Tables(1).Cell(1, 1).Range.Shading.BackgroundPatternColor =
wdColorLightYellow
.Tables(1).Cell(3, 1).Range.Shading.BackgroundPatternColor =
wdColorLightYellow
Case Is = "Silver"
.Tables(1).Cell(1, 1).Range.Shading.BackgroundPatternColor =
wdColorGray25
.Tables(1).Cell(3, 1).Range.Shading.BackgroundPatternColor =
wdColorGray25
Case Is = "Bronze"
.Tables(1).Cell(1, 1).Range.Shading.BackgroundPatternColor =
wdColorLightOrange
.Tables(1).Cell(3, 1).Range.Shading.BackgroundPatternColor =
wdColorLightOrange
End Select
.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True, _
Password:=""
End With
End Sub


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


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

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