使用复选框使区域不可编辑
Making an area un-editable using a checkbox
我有一个 word 文档,如果 checkbox
的值为 true
,我想使特定区域不可编辑(变灰)。我的问题是有一些错误,我自己无法修复,希望你能帮我解决。
Sub checkBoxStatus()
'declare variables
Dim cb3Y As CheckBox
Dim cb3N As CheckBox
Set cb3Y = ActiveDocument.FormFields(1).CheckBox
cb3Y.Value = False 'just needed this for debugging, to see if I got the right checkbox
End Sub
当运行这个代码片段时,我一直收到一条错误消息。 “运行时错误‘5941’所请求的集合成员不存在”。不幸的是,我不知道在哪里可以编辑我需要的正确复选框的 ID。
没有 CheckBox 集合。使用类似于:
Sub checkBoxStatus()
With ActiveDocument
If .FormFields(1).CheckBox.Value = True Then
' code for true here
Else
' code for false here
End If
End With
End Sub
我有一个 word 文档,如果 checkbox
的值为 true
,我想使特定区域不可编辑(变灰)。我的问题是有一些错误,我自己无法修复,希望你能帮我解决。
Sub checkBoxStatus()
'declare variables
Dim cb3Y As CheckBox
Dim cb3N As CheckBox
Set cb3Y = ActiveDocument.FormFields(1).CheckBox
cb3Y.Value = False 'just needed this for debugging, to see if I got the right checkbox
End Sub
当运行这个代码片段时,我一直收到一条错误消息。 “运行时错误‘5941’所请求的集合成员不存在”。不幸的是,我不知道在哪里可以编辑我需要的正确复选框的 ID。
没有 CheckBox 集合。使用类似于:
Sub checkBoxStatus()
With ActiveDocument
If .FormFields(1).CheckBox.Value = True Then
' code for true here
Else
' code for false here
End If
End With
End Sub