Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-04-2016, 03:31 AM
macropod's Avatar
macropod macropod is offline Multiple entries in dropdown lists Windows 7 64bit Multiple entries in dropdown lists Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


Given that the second cell doesn't even have any content controls, I can only guess at what you want.

Suppose the dropdown content control in the 1st cell is titled 'ClientA' and the dropdown content control in the 2nd cell is titled 'ClientB'. Suppose also the text content control in the 1st cell is titled 'ClientDetailsA' and the text content control in the 2nd cell is titled 'ClientDetailsB'. In that case, you could use a macro like:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim i As Long, StrDetails As String
With ContentControl
  If .Title = "ClientA" 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
    With ActiveDocument.SelectContentControlsByTitle("ClientDetailsA")(1)
      .LockContents = False
      .Range.Text = StrDetails
      .LockContents = True
    End With
  ElseIf .Title = "ClientB" 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
    With ActiveDocument.SelectContentControlsByTitle("ClientDetailsB")(1)
      .LockContents = False
      .Range.Text = StrDetails
      .LockContents = True
    End With
  End If
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 02-04-2016, 06:01 AM
Tim Tayler Tim Tayler is offline Multiple entries in dropdown lists Windows 7 64bit Multiple entries in dropdown lists Office 2010 64bit
Novice
 
Join Date: Jan 2016
Posts: 7
Tim Tayler is on a distinguished road
Default

That works perfectly! Thank you so much, macropod!!!
Reply With Quote
  #3  
Old 04-07-2016, 01:48 PM
jmglastetter jmglastetter is offline Multiple entries in dropdown lists Windows 10 Multiple entries in dropdown lists Office 2016
Novice
 
Join Date: Mar 2016
Posts: 4
jmglastetter is on a distinguished road
Default All Caps breaks the flow to the 2nd field

Hi, When trying this I could never get it to work in my document, although it worked fine in yours. I believe I have narrowed the problem down to this:

Within my document, an invoice, I want everything to be capitalized regardless of whether the user has Caps Lock on, so within font properties, I had All Caps selected.

I found that turning off All Caps fixed the issue. I also found that on your example document, by selecting all and enabling All Caps, this also broke the information from appearing.

Any thoughts as to why having All Caps on would break the information from appearing in the 2nd field?
Reply With Quote
  #4  
Old 10-28-2019, 01:52 PM
Q&A Q&A is offline Multiple entries in dropdown lists Windows 10 Multiple entries in dropdown lists Office 2010
Novice
 
Join Date: Aug 2019
Posts: 1
Q&A is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Given that the second cell doesn't even have any content controls, I can only guess at what you want.

Suppose the dropdown content control in the 1st cell is titled 'ClientA' and the dropdown content control in the 2nd cell is titled 'ClientB'. Suppose also the text content control in the 1st cell is titled 'ClientDetailsA' and the text content control in the 2nd cell is titled 'ClientDetailsB'. In that case, you could use a macro like:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim i As Long, StrDetails As String
With ContentControl
  If .Title = "ClientA" 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
    With ActiveDocument.SelectContentControlsByTitle("ClientDetailsA")(1)
      .LockContents = False
      .Range.Text = StrDetails
      .LockContents = True
    End With
  ElseIf .Title = "ClientB" 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
    With ActiveDocument.SelectContentControlsByTitle("ClientDetailsB")(1)
      .LockContents = False
      .Range.Text = StrDetails
      .LockContents = True
    End With
  End If
End With
Application.ScreenUpdating = True
End Sub
First, thank you. This thread has been very helpful. I used the quoted code in a form I'm working on which has multiple drop-down lists. Is there a way for the drop-down list to not print if I don't make a selection? For example, in the "Content Control Properties," under "Drop-Down List Properties," I have "Choose type" as my my first "Display Name" which makes it show up automatically in the drop-down list. What follows are a list of options which if selected automatically populates text in another part of the document. If I do not select one of those options and leave it as "Choose type" is there a way to make the drop-down list not print because I don't want it to show on the printed document? I want it to print as if there is no drop-down list if an option is not selected. Would I use a conditional statement? Do you have a suggestion of what I have to do to modify the code to make this work? Any other ideas?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple entries in dropdown lists Delete Multiple Entries dudeabides Office 1 07-04-2011 02:49 AM
Multiple task lists and multiple calendars kballing Outlook 0 01-18-2011 10:23 AM
Creating Multiple Contact Lists meltee78 Outlook 1 01-03-2011 09:45 PM
multiple calendar entries across a group halfhearted Outlook 0 10-11-2009 12:13 PM
Word Forms : Dropdown lists wferaera45 Word 0 04-06-2006 03:02 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft