Pattern Color of next row in table

D

Daniel

Good morning,

I have created a protected form in which there are currently 2 tables.

In the 8th row of the first table I have two check boxes (which by code are
mutually exclusive). However, I would like to control, based on the
selection made, the backcolor of the 9th row (which also happens to be the
last row in the table) of this table. Could someone show me how this is
done?! Below is my non-functional code.

************************************************************
Sub ToggleCheckBoxOnEntry()

Dim fFields As FormFields
Dim fSelectedField As FormField

Set fFields = ActiveDocument.FormFields

For Each fSelectedField In Selection.FormFields

' Form field must be a check box.
If fSelectedField.Type = wdFieldFormCheckBox Then

' Go to the case for the currently selected group.
Select Case fSelectedField.Name

'Check box group.
Case "Chk_Paper", "Chk_Electronic"
' Clear all values.
fFields("Chk_Paper").CheckBox.Value = False
fFields("Chk_Electronic").CheckBox.Value = False

Case "Chk_Original", "Chk_Copy"
' Clear all values.
fFields("Chk_Original").CheckBox.Value = False
fFields("Chk_Copy").CheckBox.Value = False

End Select

' Check the selected formfield.
fSelectedField.CheckBox.Value = True

If fFields("Chk_Electronic").CheckBox.Value = True Then
'fFields("Chk_Original").Enabled = False
'fFields("Chk_Copy").Enabled = False
ActiveDocument.Tables(1).Rows.Last.Select
With Selection
.Cells.Borders.InsideColor = 1
End With


End If

End If

Next

End Sub
************************************************************

Thank you the help,

Daniel
 
D

Doug Robbins

ActiveDocument.Tables(1).Rows(9).Range.Shading.BackgroundPatternColor =
wdColorAqua


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Daniel

Word keep generating an error "command not available" and crashes. Is it
because the form is protected? Is there a way around this problem?

Daniel
 
D

Doug Robbins

Add

ActiveDocument.Unprotect

before that code, and

ActiveDocument.Protect wdAllowOnlyFormfields, NoReset

after it.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Daniel

Doug,

It work like a charm with that addition. Thank you for your help.

I have a follow up question to this one. I have a really hard time
understanding the indexing of table..... in word and how to work with them in
coding. Is there a good website that covers this that you might recommend?

Thank you once again,

Daniel
 
D

Doug Robbins

What do you mean by "indexing of a table"?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - 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