From: Stuart Peters on
Based upon a checkbox value in the form fields I am trying to disable or
enable the remaining formfields in the table row.
I believe the following code should work. but I am gettting a run-time error
'5991' on the for each statement that says 'I cannot access individual rows
in this collection because the table has vertically merged cells'

Sub EnableActionFields()
' Enable or Disable the Actions formfields
Dim ffname As String
Dim ActField As FormField
ffname = Selection.FormFields(1).Name
For Each ActField In ActiveDocument.FormFields(ffname).Range.Rows(1)
If ActiveDocument.FormFields(ffname).CheckBox.Value = True Then
'Field checked - No action required
ActField.Enabled = False 'Already have info disable this action
Else
'Field Unchecked - Action is required
ActField.Enabled = True 'Need to assign Action,method, & dates
End If
Next

End Sub

Any ideas for a work around?

Thanks,
Stuart
From: Doug Robbins - Word MVP on
If you are trying to make the checkbox formfields act like radio buttons,
see the article "Making groups of Check Box Form Fields mutually exclusive
(so that they behave like radio buttons)” at:

http://www.word.mvps.org/FAQs/TblsFldsFms/ExclusiveFmFldChbxs.htm

using the following code in place of that in the article

Sub MakeCheckBoxesExclusive()
Dim oField As FormField
For Each oField In Selection.Rows(1).Range.FormFields
oField.CheckBox.Value = False
Next oField
Selection.FormFields(1).CheckBox.Value = True
End Sub


--
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, originally posted via msnews.microsoft.com

"Stuart Peters" <StuartPeters(a)discussions.microsoft.com> wrote in message
news:8EE06254-D356-4F3D-9093-65492BB184CC(a)microsoft.com...
> Based upon a checkbox value in the form fields I am trying to disable or
> enable the remaining formfields in the table row.
> I believe the following code should work. but I am gettting a run-time
> error
> '5991' on the for each statement that says 'I cannot access individual
> rows
> in this collection because the table has vertically merged cells'
>
> Sub EnableActionFields()
> ' Enable or Disable the Actions formfields
> Dim ffname As String
> Dim ActField As FormField
> ffname = Selection.FormFields(1).Name
> For Each ActField In ActiveDocument.FormFields(ffname).Range.Rows(1)
> If ActiveDocument.FormFields(ffname).CheckBox.Value = True Then
> 'Field checked - No action required
> ActField.Enabled = False 'Already have info disable this action
> Else
> 'Field Unchecked - Action is required
> ActField.Enabled = True 'Need to assign Action,method, & dates
> End If
> Next
>
> End Sub
>
> Any ideas for a work around?
>
> Thanks,
> Stuart

From: Stuart Peters on
Thanks for the reply Doug, No, I am actually trying to make the form
Dynamic. The remaining fields are a mix of textboxes and Date fields.
I may just have to rebuild the tables to remove the vertically merged rows.
Is there a way to find out what rows have been merged? Maybe that is the
solution?

"Doug Robbins - Word MVP" wrote:

> If you are trying to make the checkbox formfields act like radio buttons,
> see the article "Making groups of Check Box Form Fields mutually exclusive
> (so that they behave like radio buttons)” at:
>
> http://www.word.mvps.org/FAQs/TblsFldsFms/ExclusiveFmFldChbxs.htm
>
> using the following code in place of that in the article
>
> Sub MakeCheckBoxesExclusive()
> Dim oField As FormField
> For Each oField In Selection.Rows(1).Range.FormFields
> oField.CheckBox.Value = False
> Next oField
> Selection.FormFields(1).CheckBox.Value = True
> End Sub
>
>
> --
> 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, originally posted via msnews.microsoft.com
>
> "Stuart Peters" <StuartPeters(a)discussions.microsoft.com> wrote in message
> news:8EE06254-D356-4F3D-9093-65492BB184CC(a)microsoft.com...
> > Based upon a checkbox value in the form fields I am trying to disable or
> > enable the remaining formfields in the table row.
> > I believe the following code should work. but I am gettting a run-time
> > error
> > '5991' on the for each statement that says 'I cannot access individual
> > rows
> > in this collection because the table has vertically merged cells'
> >
> > Sub EnableActionFields()
> > ' Enable or Disable the Actions formfields
> > Dim ffname As String
> > Dim ActField As FormField
> > ffname = Selection.FormFields(1).Name
> > For Each ActField In ActiveDocument.FormFields(ffname).Range.Rows(1)
> > If ActiveDocument.FormFields(ffname).CheckBox.Value = True Then
> > 'Field checked - No action required
> > ActField.Enabled = False 'Already have info disable this action
> > Else
> > 'Field Unchecked - Action is required
> > ActField.Enabled = True 'Need to assign Action,method, & dates
> > End If
> > Next
> >
> > End Sub
> >
> > Any ideas for a work around?
> >
> > Thanks,
> > Stuart
>
From: Fumei2 via OfficeKB.com on
VBA can not actioned against merged cells. Period. It simply will not.

I am wondering about:

For Each ActField In ActiveDocument.FormFields(ffname).Range.Rows(1)

This is saying: For Each FORMFIELD in ExplicitFormfield.Range.Rows(1)

This is very odd.

The objects does not match. The IN object is a Row...not formfields. There
should be an error for this.

For Each ActField In ActiveDocument.FormFields("Text1").Range _
.Rows(1).Range.FormFields

should work though.

Unless there are merged cells.
Stuart Peters wrote:
>Thanks for the reply Doug, No, I am actually trying to make the form
>Dynamic. The remaining fields are a mix of textboxes and Date fields.
>I may just have to rebuild the tables to remove the vertically merged rows.
>Is there a way to find out what rows have been merged? Maybe that is the
>solution?
>
>> If you are trying to make the checkbox formfields act like radio buttons,
>> see the article "Making groups of Check Box Form Fields mutually exclusive
>[quoted text clipped - 41 lines]
>> > Thanks,
>> > Stuart

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/201003/1

From: Fumei2 via OfficeKB.com on
"Is there a way to find out what rows have been merged? "

Not easily. You can try checking against the ColumnIndex for the last cell,
in each row.

So if the last cell of Row1 has a ColumnIndex = 3, and the last cell of Row3
has a ColumnIndex = 2, then you know Row3 has a merged cell.

HOWEVER, you do NOT know which one, nor can you.

I avoid merged cells; they screw up VBA badly. If you need things to look
like they are merged, play around with the format of the cells (borders etc.)
rather than merge.

Fumei2 wrote:
>VBA can not actioned against merged cells. Period. It simply will not.
>
>I am wondering about:
>
>For Each ActField In ActiveDocument.FormFields(ffname).Range.Rows(1)
>
>This is saying: For Each FORMFIELD in ExplicitFormfield.Range.Rows(1)
>
>This is very odd.
>
>The objects does not match. The IN object is a Row...not formfields. There
>should be an error for this.
>
>For Each ActField In ActiveDocument.FormFields("Text1").Range _
> .Rows(1).Range.FormFields
>
>should work though.
>
>Unless there are merged cells.
>>Thanks for the reply Doug, No, I am actually trying to make the form
>>Dynamic. The remaining fields are a mix of textboxes and Date fields.
>[quoted text clipped - 7 lines]
>>> > Thanks,
>>> > Stuart

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/201003/1

 |  Next  |  Last
Pages: 1 2
Prev: Date incrimintation
Next: Date increments