Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 使用复选框使区域不可编辑_Vba_Checkbox_Ms Word_Office365 - Fatal编程技术网

Vba 使用复选框使区域不可编辑

Vba 使用复选框使区域不可编辑,vba,checkbox,ms-word,office365,Vba,Checkbox,Ms Word,Office365,我有一个word文档,如果复选框的值为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 debuggi

我有一个word文档,如果
复选框
的值为
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。

没有复选框集合。使用类似于:

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文档中有2个
复选框。如果选择了另一个,如何禁用一个?我试过这样做:
Dim cb1 As Checkbox Dim cb2 As Checkbox cb1=FormFields(1)。Checkbox'这里是另一个不起作用的代码。我只想把我的复选框(名为cb1)声明为一个变量,用它做很多事情。你有没有费心去读我贴的答案???正如我所说,“没有复选框集合”。网上有很多让formfield复选框成为独家的例子。是的,谢谢,我当时不明白你的意思。我不明白你的意思。不管怎样,你的回答解决了我的问题。谢谢