View Single Post
 
Old 08-02-2021, 10:30 PM
cookietyrant cookietyrant is offline Windows 10 Office 2019
Novice
 
Join Date: Aug 2021
Posts: 2
cookietyrant is on a distinguished road
Angry Content Controls - Multiple Drop Downs - VBA

Basically I have 2 Fields of which I want to have a drop down for with unique data the below code works perfectly for my Project manager section, but then when I want to run it against the engineer section it won't fill in the Engineer details section...I'm assuming there is some sort of join or piece of code I'm missing to get multiple drop downs utilizing the below code to act independent of each other.

I attached a screen shot of which may help show what I'm trying to do...

HTML Code:
Option Explicit

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, StrDetails As String
With ContentControl
  If .tag = "ProjectManager" Then
  For i = 1 To .DropdownListEntries.Count
    If .DropdownListEntries(i).Text = .Range.Text Then
      StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11))
      Exit For
    End If
  Next
  ActiveDocument.ContentControls(2).Range.Text = StrDetails
  End If
End With
End Sub
HTML Code:
Option Explicit

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, StrDetails As String
With ContentControl
  If .tag = "Engineer" Then
  For i = 1 To .DropdownListEntries.Count
    If .DropdownListEntries(i).Text = .Range.Text Then
      StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11))
      Exit For
    End If
  Next
  ActiveDocument.ContentControls(2).Range.Text = StrDetails
  End If
End With
Attached Images
File Type: png Word Table.PNG (45.1 KB, 17 views)
Reply With Quote