首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

动态内容控件运用(一)

2013-01-28 
动态内容控件应用(一)例程目的:在一个表中,当选择None前的CheckBox后,表中的其他CheckBox会消失(以防错

动态内容控件应用(一)
例程目的:

在一个表格中,当选择"None"前的CheckBox后,表格中的其他CheckBox会消失(以防错选)。当取消选择后CheckBox会重新出现。如图:

动态内容控件运用(一)动态内容控件运用(一)

说明:此前必须将"None"前CheckBox的Title设定为"None"。

Option ExplicitPrivate Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)    Dim r, c As Integer    Dim Cel As Word.range    Dim t As String        If ContentControl.Title = "None" And ContentControl.Checked Then        For r = 1 To ActiveDocument.Tables(1).Rows.Count            For c = 1 To ActiveDocument.Tables(1).Columns.Count                Set Cel = ActiveDocument.Tables(1).Cell(r, c).range                If Cel.ContentControls(1).Title <> "None" Then                    Cel.ContentControls(1).LockContentControl = False                    Cel.ContentControls(1).Delete (True)                End If            Next        Next    ElseIf ContentControl.Title = "None" And Not ContentControl.Checked Then        For r = 1 To ActiveDocument.Tables(1).Rows.Count            For c = 1 To ActiveDocument.Tables(1).Columns.Count                Set Cel = ActiveDocument.Tables(1).Cell(r, c).range                t = Replace(Cel.Text, Chr(13), "")                If Cel.ContentControls.Count = 0 Then                    Cel.Select                    Application.Selection.range.ContentControls.Add wdContentControlCheckBox                    Application.Selection.MoveRight Unit:=wdCharacter, Count:=2                    Application.Selection.range.Text = t                End If            Next        Next    End IfEnd Sub


热点排行