View Single Post
 
Old 01-25-2014, 04:39 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit 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

First, you would need to create each of your dependent dropdown content controls, each in its own paragraph. Then you would create a custom Quick Part from each of those paragraphs (see http://office.microsoft.com/en-us/wo...010370568.aspx). Next, you'd delete those from the document and create the dropdown you'll use to choose the various options. Then, insert a continuous Section break immediately before where the dependent dropdown is to be inserted. Finally, you'd add a macro to the document's 'ThisDocument' module, coded along the lines of:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim StrNm As String
With ContentControl
  If .Title <> "Dropdown 1" Then Exit Sub
  Select Case .Range.Text
    Case "Item 1": StrNm = "Fruit"
    Case "Item 2": StrNm = "Game"
    Case Else: StrNm = ""
  End Select
End With
With ActiveDocument.Sections(2).Range.ContentControls(1)
  .LockContentControl = False
  .Delete
End With
If StrNm = "" Then Exit Sub
Application.Templates("C:\Users\" & Environ("UserName") & _
  "\Documents\Misc\Office Config\Word\Normal.dotm"). _
  BuildingBlockEntries(StrNm).Insert RichText:=True, _
  Where:=ActiveDocument.Sections(2).Range.Characters.First
End Sub
where:
• "Dropdown 1" is the title property of the master dropdown
• "Item 1" & "Item 2" are the master dropdown entry names
• "Fruit" & "Game" are the corresponding custom Quick Part names.
• the custom Quick Parts are stored in Word's 'Normal' template.
• the target Section is Section 2.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote