I've created a document with a control (a drop-down menu) that changes the content of a second control depending on what the user selects in the first one. I created the code for this in VBA, but as it stands now it all vanishes when I close the document, and I have to enter the code again.
What I need in the end is to create a control that allows readers of the document to select one of three types, and have text input fields on the page below change according to the type selected. One of these input fields should be formatted as an ol/ ordered list/ numbered list, so when the user types and hits return, a new numbered line appears. The other two types can just be free text entry fields.
I've read all of this page, as well as all of the pages it links to:
https://msdn.microsoft.com/en-us/library/3hekt07s.aspx
but I'm still pretty much lost about how to even just save the document with the functionality that I've created so far. If someone could just walk me through some of the basics that would be a great help.
Here's the VBA code:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
If ContentControl.Tag = "TypeSelect" Then
Debug.Print ContentControl.Range
Select Case ContentControl.Range
Case "Task"
ActiveDocument.ContentControls(2).Range = "Enter Steps"
Case "Concept"
ActiveDocument.ContentControls(2).Range = "Enter Descriptive Content"
Case Else
ActiveDocument.ContentControls(2).Range = "Enter Reference Data"
End Select
End If
End Sub
This is in
Code:
Project (NameOfMyDocument)
MicrosoftWordObjects
ThisDocument
On the page I have two controls, and the first one controls what the other one displays-- until I close the whole thing and open it again, at which point the above code is gone. The above code changes one control as you exit another, whereas what I really need is a control that changes a text field and its formatting.
Thanks in advance