![]() |
|
#1
|
|||
|
|||
|
I'm working a document in word where I need there to be a series of 3 dropdowns. The first drop down allows you to pick a team. Once you select that team, certain names of that respective team appear with their contact information populate in the text box. How do I get all 3 boxes to work together, where once you select the Team, then the contact name, the info populates in the contact detail box. I already have two codes that I've gotten to work separately, but not together on the same document. I also need to be able to input this in different locations of the document without it changing previously entered information. Last edited by maric; 07-21-2022 at 06:12 AM. |
|
#2
|
|||
|
|||
|
What is your question?
|
|
#3
|
|||
|
|||
|
How can I combine the two codes to work together within the one document? Currently the code between Service teams and contact members work, however I cant get the contact details to appear into the text box.
|
|
#4
|
||||
|
||||
|
Post a document with your working code and Content Controls so someone can add the additional coding for contact details.
The contact details can be manually entered in the code or it can be stored in a non-vba location which would make those contact details easier to maintain.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#5
|
|||
|
|||
|
Would you be able to take a look at it?
|
|
#6
|
|||
|
|||
|
Just nest your two "If .Title .... End If" statements in your With CCtrl ... End If statement.
|
|
#7
|
|||
|
|||
|
Would you be able to actually write out the exact code. As I'm still getting a debug message.
|
|
#8
|
|||
|
|||
|
What debug message? We (or at least I am) are not here to write code for you! Where is the complete segment of code that you have written?
|
|
#9
|
|||
|
|||
|
I meant a compile error and as provided in the attachments above, I already have both codes written. I'm just having trouble getting them to work together. That's why I came to this forum, for help! Also as you can see in another comment I was told to add the document so that someone could help with the additional coding needed.
|
|
#10
|
|||
|
|||
|
I saw very little evidence in your attached document where you had made any effort to combine the code as I suggested.
Code:
Option Explicit
Dim StrOption As String
Private Sub Document_ContentControlOnEnter(ByVal CCtrl As ContentControl)
If CCtrl.Title = "Service Team" Then StrOption = CCtrl.Range.Text
End Sub
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim i As Long, StrOut As String
Dim strDetails As String
With CCtrl
If .Title = "Service Team" Then
If StrOption = .Range.Text Then Exit Sub
Select Case .Range.Text
Case "Producer"
StrOut = "Apples,Banna,Pear,Oranges"
Case "Account Manager"
StrOut = "Math,History,English,Art"
Case "Claims Advocate"
StrOut = "Scissors,Paper,Rock"
Case Else
.Type = wdContentControlText
.Range.Text = ""
.Type = wdContentControlDropdownList
End Select
With ActiveDocument.SelectContentControlsByTitle("Contact Name")(1)
.DropdownListEntries.Clear
For i = 0 To UBound(Split(StrOut, ","))
.DropdownListEntries.Add Split(StrOut, ",")(i)
Next
.Type = wdContentControlText
.Range.Text = ""
.Type = wdContentControlDropdownList
End With
End If
If .Title = "Contact Name" 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.SelectContentControlsByTitle("Contact Details").Item(1).Range.Text = strDetails
End If
End With
Application.ScreenUpdating = True
End Sub
|
|
#11
|
|||
|
|||
|
I was trying to be helpful keeping them separated, however I appreciate the time you took to look at it, thank you.
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
List of ascii code of Character Symbols or code for all symbols used in Word
|
SamDsouza | Word VBA | 3 | 03-12-2020 04:49 AM |
AutoOpen code to change date code to date text
|
Legal Learning Center | Word VBA | 6 | 02-22-2020 02:24 PM |
Enabling concurrent multiple editors of 1 word document over network drive.
|
tyrese213 | Word | 4 | 01-02-2019 06:47 PM |
| Concurrent Calls in Excel | sbcccc | Excel | 1 | 08-15-2018 12:24 AM |
VBA Code to search for field codes with certain text before the Field code and to change style
|
welcometocandyland | Word VBA | 4 | 02-08-2017 06:53 PM |