View Single Post
 
Old 02-17-2023, 01:42 PM
ireneb ireneb is offline Windows 10 Office 2019
Novice
 
Join Date: Jan 2023
Posts: 2
ireneb is on a distinguished road
Default Insert text and fieldformtext when dropdown selected

I want to add standard text in bold if possible then a form text if my drop down is selected as yes.

Similarly I want this specific drop down and text to go away if the form is reset.

It would look something like:
On Protocol: {FORMDROPDOWN} (called ddProtocol with 3 options Choose One, Yes, No) If yes is selected tab from drop down bold: Refer to Protocol: {FORMTEXT} labeled Protocoltest

If Choose One or No are selected make sure none of the above items are occurring but don't just delete every form text field because there are a lot of others in the full document.


Abbreviated version of the code is as follows which I tried to just get the option to work if I selected Yes and makes the form text field appear RIGHT behind the ddProtocol and there is no text showing:

Dim xProtocol As FormField
Dim xState As FormField
On Error Resume Next
Set xProtocol = ActiveDocument.FormFields("ddProtocol")
Set xState = ActiveDocument.FormFields("ddConstraints")
With xState.DropDown.ListEntries
.Clear
Select Case xProtocol.Result
Case "Yes"
Options.ReplaceSelection = False
With Selection
Selection.TypeText vbTab & "Refer to Protocol:" & vbTab
End With

Selection.Collapse Direction:=wdCollapseEnd
Set ffield = ActiveDocument.FormFields _
.Add(Range:=Selection.Range, Type:=wdFieldFormTextInput)
With ffield
.Name = "Protocoltest"
.TextInput.EditType Type:=wdRegularText
.TextInput.Width = 11
End With
Case "No"
' Insert code to erase here
End Select
End With

Thanks for your help!!
Reply With Quote