Home > Software engineering >  The change of the content of the word, please check box control events is which?
The change of the content of the word, please check box control events is which?

Time:09-16

Click the checkbox content control (is content control, wdContentControlCheckBox), display will change, I think after click, according to state something, but did not find a way to trigger events, that is, please? thank you

CodePudding user response:

 Private Sub CheckBox1_Click () 
If Me. Controls (" CheckBox1 "). The Value=https://bbs.csdn.net/topics/True Then
'checkbox to change information
Me. Controls (" CheckBox1 "). The Caption="you point to Me"
The Else
'checkbox content original information
Me. Controls (" CheckBox1 "). The Caption="CheckBox1"
End the If
End Sub

CodePudding user response:

reference 1st floor humanmagic response:
 Private Sub CheckBox1_Click () 
If Me. Controls (" CheckBox1 "). The Value=https://bbs.csdn.net/topics/True Then
'checkbox to change information
Me. Controls (" CheckBox1 "). The Caption="you point to Me"
The Else
'checkbox content original information
Me. Controls (" CheckBox1 "). The Caption="CheckBox1"
End the If
End Sub


Thank you for your help, but I was using a content control (ContentControl), not the CheckBox controls,

CodePudding user response:

The front desk, Document events
The cases of incident is chosen to leave
 Private Sub Document_ContentControlOnExit (ByVal ContentControl As ContentControl, Cancel the As Boolean) 
The Select Case ContentControl. Range. The Text
Case "Cat"
The Debug. Print "cats"
Case "Dog"
The Debug. Print "dog"
End the Select
End Sub

CodePudding user response:

reference 4 floor humanmagic response:
reception, Document events
The cases of incident is chosen to leave
 Private Sub Document_ContentControlOnExit (ByVal ContentControl As ContentControl, Cancel the As Boolean) 
The Select Case ContentControl. Range. The Text
Case "Cat"
The Debug. Print "cats"
Case "Dog"
The Debug. Print "dog"
End the Select
End Sub

My idea is that there is a table in a word document, in the form of a grid is a check box controls content, when click the checkbox, if checked, a red color, if the state is not selected is the base of color is green, don't know how to implement, thank you.

CodePudding user response:

reference 4 floor humanmagic response:
reception, Document events
The cases of incident is chosen to leave
 Private Sub Document_ContentControlOnExit (ByVal ContentControl As ContentControl, Cancel the As Boolean) 
The Select Case ContentControl. Range. The Text
Case "Cat"
The Debug. Print "cats"
Case "Dog"
The Debug. Print "dog"
End the Select
End Sub




CodePudding user response:

Take it, don't thank, remember to put the document in the
 Private Sub Document_ContentControlOnExit (ByVal ContentControl As ContentControl, Cancel the As Boolean) 
If ContentControl. Checked Then
ContentControl. Range. Cells (1). The Shading. BackgroundPatternColorIndex=wdRed
The Else
ContentControl. Range. Cells (1). The Shading. BackgroundPatternColorIndex=wdGreen
End the If
End Sub

CodePudding user response:

refer to 7th floor humanmagic response:
take go to, don't thank, remember to put the document in the
 Private Sub Document_ContentControlOnExit (ByVal ContentControl As ContentControl, Cancel the As Boolean) 
If ContentControl. Checked Then
ContentControl. Range. Cells (1). The Shading. BackgroundPatternColorIndex=wdRed
The Else
ContentControl. Range. Cells (1). The Shading. BackgroundPatternColorIndex=wdGreen
End the If
End Sub


Thank you very, very, have solved the problem,
  •  Tags:  
  • VBA
  • Related