![]() |
|
#1
|
|||
|
|||
|
I have two Checkboxes
Checkbox 1 - Paragraph 1 (Bookmark1) Checkbox 2 - Paragraph 2 (Bookmark2) I want the two paragraph to stay visible but when the client choose Checkbox1 then the Checkbox2 - paragraph 2 is hidden and viseversa. Is this possible and easy to do? |
|
#2
|
|||
|
|||
|
Probably but what exactly are your trying to do.
|
|
#3
|
|||
|
|||
|
I have two paragraphs that the client needs to choose from. So if he Click on the checkbox1 I want Checkbox 2 to be hidden, and if he clicked on Checkbox2 I want Checkbox1 to be hidden.
|
|
#4
|
|||
|
|||
|
And what should happen wrt to the obstinate client who choose neither, or the indecisive client who chooses checkbox1 or checkbox2 and then changes his or her mind?
A alternate method is neither paragraph is shown until the client makes up his or her mind and chooses and give the client a means of changing their mind. |
|
#5
|
|||
|
|||
|
They need to pick one. If he checked the first one, and then he chnaged his mind then he will uncheck and the checkbox 2 appear and check it.
|
|
#6
|
|||
|
|||
|
This seems a convoluted process but yes it is certainly possible. See attached document and image.
You will need to create the three different conditions 0) a rich text cc (Titled Result) with both check boxes and text showing 1) a richtext CC (Titled Result1) with Checkbox1 and text only 2) a rich text CC (Titled Result2) with Checkbox 2 and text only and an overall result richtext CC (titled Result) showing both checkboxes and text. These will have to be mapped to a customXMLpart. Once done, you can remove the Result0, Result1 and Result2 richtext CCs and content. You will need the following code in the ThisDocument class object: Code:
Private Sub Document_ContentControlBeforeStoreUpdate(ByVal CC As ContentControl, Content As String)
Select Case CC.Title
Case "Checkbox1"
'Reset so Result CC shows both checkboxes and paragraphs (Result0 node value)
CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result[1]").Text = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result0[1]").Text
If CC.Checked Then
'Remap Result CC to show only checkbox 1 and text (Result1 node value)
CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result[1]").Text = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result1[1]").Text
End If
Case "Checkbox2"
'Reset so Result CC shows both checkboxes and paragraphs (Result0 node value)
CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result[1]").Text = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result0[1]").Text
'Remap Result CC to show only checkbox 2 and text (Result2 node value)
If CC.Checked Then
CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result[1]").Text = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result2[1]").Text
End If
End Select
End Sub
Last edited by Charles Kenyon; 11-13-2020 at 11:55 AM. Reason: make list more readable |
|
#7
|
|||
|
|||
|
Hi Greg thanks for helping, I tried badly to open your word document but it is not working. I am new to VBA and I couldn't follow your step. So I made something simple and it work. I have another question.
I created the attached document that includes in it a VBA user field to fill the fields in the documents with a bookmark. The VBA will run when you open the document and ask you the questions, anyway. Also, I want the document to be password protected so no one can change anything except the field that is open to them to fill by the VBA. When I protect the document, the VBA doesn't run. Is there a code for that or a solution? |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Inserting text from a Userform into a Field in a paragraph in a paragraph in a word document | storemaz | Word VBA | 1 | 03-13-2020 08:11 AM |
Text disappear on ms-word 2010 when press "show/hide Paragraph"
|
francescof | Word | 2 | 03-27-2019 01:35 AM |
| Hide and display pictures | Ljungwe | Drawing and Graphics | 1 | 04-26-2018 04:46 AM |
Help with Hide/Display of sections of document based on Drop Down selections
|
turnquistcm | Word | 2 | 05-03-2017 07:05 PM |
How to manage (display/hide) parts of the text within a document via table of content
|
Curby | Word | 2 | 06-30-2016 12:29 AM |