Black and Gray

R

rob p

I needed to suppress (I changed to gray instead) text in cells in checkbox
not checked along with the three cells next to it. Bold text if checked.
Astrid helped me out with code. I needed to change the cells next to the
checkbox too.
Here is what I have. (Toggleprotectdocument turns on / off lock). On a
simple table this macro works.

On a more complicated table with many varying sized cells, the first
checkbox seems to work. Going to the next checkbox, I then get an error 4120
bad parameter on the line with stars.

How can I tighten up the code / and further debug. Showing me that line
isn't helping. I can't see what is wrong. I seem to get the error with the
box checked or not. Also macro runs on exit.
Thanks.

Sub togglemulticells()
Let col = 0
Let Row = 0
col = Selection.Cells(1).ColumnIndex ' find cell I am
in and 3 over for range
Row = Selection.Cells(1).RowIndex ' find row
Set myTable = ActiveDocument.Tables(1)
Set myrange = ActiveDocument.Range(myTable.Cell(Row, col) _
.Range.Start, myTable.Cell(Row, col + 3).Range.End)
ToggleProtectDocument
MsgBox Row
MsgBox col
*** If ActiveDocument.FormFields(FormfieldName()).CheckBox.Value = True
Then ***
myrange.Font.Color = wdColorBlack ' works
Else
myrange.Font.Color = wdColorGray50 ' works
End If
ToggleProtectDocument
End Sub
 
W

Word Heretic

G'day "rob p" <nospam*[email protected]>,

FormfieldName() seems nonsensical, what is it standing for?

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


rob p reckoned:
 
R

Rob Peterson

Hi. It's a sub that is supposted to find field name. I got from another
example. It is as follows:

Function FormfieldName() As Variant

If Selection.FormFields.Count = 1 Then
FormfieldName = Selection.FormFields(1).Name
ElseIf Selection.FormFields.Count = 0 And Selection.Bookmarks.Count > 0
Then
FormfieldName = Selection.Bookmarks(Selection.Bookmarks.Count).Name
End If

End Function
 

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