View Single Post
 
Old 04-02-2013, 08:16 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit 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

You could add the entries to a dropdown content control. As the dropdown only supports a single line per entry, the other data could be output to a plain text or rich text content control via an on_exit macro (i.e. you must exit the dropdown content control after updating it for the conditional output to appear). See attached demo. If you examine the dropdown, you'll see the Client names appear. And, if you examine the dropdown's properties, you'll see that for each client name, the 'Value' field contains the dependent data, with the different output lines separated by | characters, as in:
Phone: 08 1111 1111|Fax: 08 2222 2222|Email: sales@roundhousenurseries.com.au
The code is:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, StrDetails As String
With ContentControl
  If .Title = "Client" 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
To access the macro in the attached document, open it and press Alt-F11.
Attached Files
File Type: zip Content Controls - Dropdown Dependent Text.zip (32.0 KB, 3290 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote