Jan 12 2022 05:15 AM
HI
My problem:
I have a form made in Word, that my colleagues have to fill out relative often, at the beginning of a new task.
The form is pretty long because it has to to be flexible enough to meet everybodys needs. Therefore it has 9 predefined form-sections the user can fill. Often the user only needs to fill one or two of the possible sections. This creates a document thats allways much longer than needed.
The solution I cant use:
The easy solution to that would be to design the form as an online-form, as a simpel survey, that adapts to users needs for txt-response. But, -due to regulations this specifick form must be offline and even not a database. :(
A solution in Word???
Can a Word-form behave adaptive according to a user-choice?
Example:
The user starts to fill tre check-boxes in the first section of the word-form. Could be...
I need to report an:
- Observation (Checkbox)
- Incident (Checkbox)
- Information (Checkbox)
Depending on the checkbox choises, the form the automaticaly adapts and inserts ( or just show/hide) a predefined form-section to fill out?
Jan 13 2022 01:16 AM
Jan 13 2022 03:21 AM
Jan 13 2022 10:44 PM
SolutionTo make the code a bit simpler, I would suggest that each section of the form be in a separate Section of the document - Form section 1 in Document Section 2, Form section 2 in Document Section 3, --- Form section 8 in Document Section 9, Form section 9 in Document Section 10, and you have the Nine check boxes in Section 1, with the Titles of the Check boxes being Section 1, Section 2, --- Section 8, Section 9.
Then, in Visual Basic Editor in the ThisDocument object insert the following code
Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)
Dim Secnum As Long
For Each CC In ActiveDocument.ContentControls
If Left(CC.Title, 7) = "Section" Then
Secnum = Mid(CC.Title, 9)
If CC.Checked = True Then
ActiveDocument.Sections(Secnum + 1).Range.Font.Hidden = False
Else
ActiveDocument.Sections(Secnum + 1).Range.Font.Hidden = True
End If
End If
Next
End Sub
Then, if you have the display of Hidden text disabled (Via File>Display) when you check any of the text boxes and exit from the text box, the code will format the text of the Section of the document for which the associated checkbox is checked so that the font is not hidden and for any Section for which the associated checkbox is not checked so that it is hidden and will not therefore appear.
Unfortunately, while a macro enabled workbook (xlsm) can be attached to a response, a macro enabled Word document or template cannot be attached. If you contact me at dougrobbinsmvp[atsymbol]gmail[dot]com, I will send you the macro enabled template that I created to respond to your question.
Jan 18 2022 02:21 AM
Jan 18 2022 04:38 AM
Jan 13 2022 10:44 PM
SolutionTo make the code a bit simpler, I would suggest that each section of the form be in a separate Section of the document - Form section 1 in Document Section 2, Form section 2 in Document Section 3, --- Form section 8 in Document Section 9, Form section 9 in Document Section 10, and you have the Nine check boxes in Section 1, with the Titles of the Check boxes being Section 1, Section 2, --- Section 8, Section 9.
Then, in Visual Basic Editor in the ThisDocument object insert the following code
Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)
Dim Secnum As Long
For Each CC In ActiveDocument.ContentControls
If Left(CC.Title, 7) = "Section" Then
Secnum = Mid(CC.Title, 9)
If CC.Checked = True Then
ActiveDocument.Sections(Secnum + 1).Range.Font.Hidden = False
Else
ActiveDocument.Sections(Secnum + 1).Range.Font.Hidden = True
End If
End If
Next
End Sub
Then, if you have the display of Hidden text disabled (Via File>Display) when you check any of the text boxes and exit from the text box, the code will format the text of the Section of the document for which the associated checkbox is checked so that the font is not hidden and for any Section for which the associated checkbox is not checked so that it is hidden and will not therefore appear.
Unfortunately, while a macro enabled workbook (xlsm) can be attached to a response, a macro enabled Word document or template cannot be attached. If you contact me at dougrobbinsmvp[atsymbol]gmail[dot]com, I will send you the macro enabled template that I created to respond to your question.