我有4列,每个列有2组复选框,我想循环遍历每一组,检查两个复选框是否都被选中,如果它们然后退出子并放置项目的名称,在1组中选中2个复选框一个msgbox。
Set oRow = oTable.Rows
Set oTable = doc.Tables(3)
For Each oRow In oTable.Rows
With oRow
If .Cells(3).Range.Text <> .Cells(3).Range.Text <> "Prep" Or .Cells(3).Range.Text <> "Y" Or .Cells(3).Range.Text <> "" Then
If .Cells(3).ParentContentControl.Checked = True And .Cells(4).ParentContentControl.Checked = True Then 'error here
MsgBox "The following item has both preparer and reviewer checked:" & .Cells(2)
Exit Sub
ElseIf .Cells(5).ParentContentControl.Checked = True And .Cell(6).ParentContentControl.Checked = True Then
MsgBox .Cell(2)
Exit Sub
End If
End If
End With
Next oRow
问题是我一直在收到错误。
运行时错误'438',对象不支持此属性或方法。
要访问嵌入在表格中的ContentControl
,请在单元格中进行以下参考:
If .Cells(3).Range.ContentControls(1).Checked = True And .Cells(4).Range.ContentControls(1).Checked = True Then