![]() |
|
#6
|
||||
|
||||
|
You need to combine the code. You can use Select Case to process as many controls as you wish by addressing them by their title property e.g.
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long
Dim oCC As ContentControl
With ContentControl
Select Case .Title
Case Is = "Client"
If .ShowingPlaceholderText = True Then
Set oCC = ActiveDocument.SelectContentControlsByTitle("ClientDetails").Item(1)
oCC.LockContentControl = True
oCC.Range.Text = ""
Else
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
Select Case .DropdownListEntries(i).Text
Case "Roundhouse Nurseries"
AutoTextToCC "ClientDetails", ActiveDocument.AttachedTemplate, "Roundhouse"
Case "Smiths Wholesales"
AutoTextToCC "ClientDetails", ActiveDocument.AttachedTemplate, "Smith"
End Select
Exit For
End If
Next
End If
Case Is = "Another listbox"
If .ShowingPlaceholderText = True Then
Set oCC = ActiveDocument.SelectContentControlsByTitle("CC to be processed").Item(1)
oCC.LockContentControl = True
oCC.Range.Text = ""
Else
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
Select Case .DropdownListEntries(i).Text
Case "List Item 1"
AutoTextToCC "CC to be processed", ActiveDocument.AttachedTemplate, "Autotext Name 1"
Case "List Item 2"
AutoTextToCC "CC to be processed", ActiveDocument.AttachedTemplate, "Autotext Name 2"
End Select
Exit For
End If
Next
End If
End Select
End With
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Multiple entries in dropdown lists
|
paul_pearson | Word VBA | 154 | 11-08-2025 03:51 PM |
| Muliple entries in Multiple dropdown lists | Haygordon | Word VBA | 7 | 04-04-2019 06:28 AM |
| VBA Word - Building Block (AutoText) - Array - Replace Text with Specific Building Blocks | jc491 | Word VBA | 7 | 01-03-2016 10:34 PM |
Open Quickpart file normalemail.dotm - edit multiple building blocks
|
rollno | Word | 7 | 02-24-2014 04:29 PM |
| Building blocks show correctly in dropdown, but wrong building block populates in doc | wordgirl123 | Word | 0 | 10-03-2013 08:30 AM |