Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2017, 08:09 AM
LaurenM LaurenM is offline Dropdown dependencies with multiple dropdowns Windows XP Dropdown dependencies with multiple dropdowns Office 2010 32bit
Novice
Dropdown dependencies with multiple dropdowns
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default Dropdown dependencies with multiple dropdowns

I have used the content control code in https://www.msofficeforums.com/word-...own-lists.html successfully to allow users to select an item from a dropdown list located in the Header of a Word template. Thank you Macropod. The selected item then displays in a text box in the subsequent header. However I need to be able to interchange the headers (when the document is translated), with the new textbox displaying the new selection. The Headers inclusive of the Content Controls are saved as Quick Parts, that various editors will insert as they translate the document. Users may add any number of new Content Control Headers with the subsequent pages always needing to reflect the section's chosen dropdown item. How do I always refer to the next text box, and also ensure that the previous text boxes do not change? With thanks in advance.
Reply With Quote
  #2  
Old 11-21-2017, 03:24 PM
macropod's Avatar
macropod macropod is offline Dropdown dependencies with multiple dropdowns Windows 7 64bit Dropdown dependencies with multiple dropdowns Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 change the line:
Code:
ActiveDocument.ContentControls(2).Range.Text = StrDetails
to:
Code:
    With ActiveDocument.SelectContentControlsByTitle("ClientDetails")
      .Item(.Count).Range.Text = StrDetails
    End With
where 'ClientDetails' is the title you give to the output content control. That way, the output will always go to the last output content control in the document.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-22-2017, 12:08 AM
LaurenM LaurenM is offline Dropdown dependencies with multiple dropdowns Windows XP Dropdown dependencies with multiple dropdowns Office 2010 32bit
Novice
Dropdown dependencies with multiple dropdowns
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

Thank you Macropod

At the moment I have this:

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, StrDetails As String
With ContentControl
  If .Title = "CHOOSE SECTOR" 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
    TextBoxLauren.Text = StrDetails
   ElseIf .Title = "CHOOSE SECTOR XHO" 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
    TextBoxLauren.Text = StrDetails
    Else
End If

End With

End Sub
I also need to lock the previous outputs so that if the sector changes mid report (in a new section) the previous outputs will remain unchanged. I hope this makes sense. Thank you in anticipation.
Attached Images
File Type: jpg Section Headers 1.jpg (80.1 KB, 25 views)
File Type: jpg Section Headers 2.jpg (20.6 KB, 25 views)

Last edited by macropod; 11-22-2017 at 01:05 AM. Reason: Added code tags
Reply With Quote
  #4  
Old 11-22-2017, 01:13 AM
macropod's Avatar
macropod macropod is offline Dropdown dependencies with multiple dropdowns Windows 7 64bit Dropdown dependencies with multiple dropdowns Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

I see you code is writing to textboxes, via:
TextBoxLauren.Text = StrDetails
Obviously, though, if you content controls are all using the same code, they'll all write to the same textbox. You need some way of differentiating the destinations. So, why are you writing to a textbox, and where is that textbox situated?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 11-22-2017, 01:14 AM
LaurenM LaurenM is offline Dropdown dependencies with multiple dropdowns Windows XP Dropdown dependencies with multiple dropdowns Office 2010 32bit
Novice
Dropdown dependencies with multiple dropdowns
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

Hi Macropod. The word 'ECONOMICS' is the text box. I guess it doesn't necessarily need to be a text box but does need to show the name of the sector selected in the main heading. The textbox is within the header, and the headers all need to be available as Quick Parts
Reply With Quote
  #6  
Old 11-22-2017, 01:21 AM
LaurenM LaurenM is offline Dropdown dependencies with multiple dropdowns Windows XP Dropdown dependencies with multiple dropdowns Office 2010 32bit
Novice
Dropdown dependencies with multiple dropdowns
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

I think I can simplify it like this. The template consists of
1. FRONT PAGE with a dropdown, the output of which needs to be reflected in the subsequent sub headers
2. COMPANY PAGE Quick Part Header with Dropdown, the output of which needs to be reflected in COMPANY PAGE Quick Part Sub Header

Both the FRONT PAGE and subheader, and the company page header and related sub header Quick Parts need to be available in two languages, and insertable as many times as the user requires.
Reply With Quote
  #7  
Old 11-22-2017, 02:26 AM
macropod's Avatar
macropod macropod is offline Dropdown dependencies with multiple dropdowns Windows 7 64bit Dropdown dependencies with multiple dropdowns Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

If your dropdown is in the header, you shouldn't need anything more than that, unless you're using a 'different first page' and/or 'different odd and even' page setup, as the dropdown selection will appear on all pages in that Section.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 11-22-2017, 05:05 AM
LaurenM LaurenM is offline Dropdown dependencies with multiple dropdowns Windows XP Dropdown dependencies with multiple dropdowns Office 2010 32bit
Novice
Dropdown dependencies with multiple dropdowns
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

I do have a different first page In the attached, the sub header on p4 is picking up the selection from the cover page, rather than from the page just before it 'INSERT COMPANY NAME'
Attached Images
File Type: png Headers.png (79.7 KB, 26 views)
Reply With Quote
  #9  
Old 11-22-2017, 05:11 AM
macropod's Avatar
macropod macropod is offline Dropdown dependencies with multiple dropdowns Windows 7 64bit Dropdown dependencies with multiple dropdowns Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Try the following code. Do be careful, though, as it both deletes the content control title and converts the dropdown to a text content control as part of the 'locking' process you wanted. For the output, you'll need a text content control in whichever of the Section's headers you don't have the content control in. The code works equally well with or without a 'different first page' and/or 'different odd and even' page setup.

The other thing to be aware of is that, with content controls in the header, you need to click somewhere else in the header for the macro to run.
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Dim StrDetails As String, HdFt As HeaderFooter
With CCtrl
  If .Title = "Sector" Then
    If .ShowingPlaceholderText = True Then Exit Sub
    .Title = ""
    StrDetails = .Range.Text
    .LockContentControl = False
    .Type = wdContentControlText
    For Each HdFt In .Range.Sections(1).Headers
      With HdFt
        If .Exists Then
          If .Range.ContentControls.Count = 1 Then
            With .Range.ContentControls(1)
              .LockContents = False
              .Range.Text = StrDetails
              .LockContents = True
              .LockContentControl = True
            End With
          End If
        End If
      End With
    Next
  End If
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 11-22-2017, 11:46 PM
LaurenM LaurenM is offline Dropdown dependencies with multiple dropdowns Windows XP Dropdown dependencies with multiple dropdowns Office 2010 32bit
Novice
Dropdown dependencies with multiple dropdowns
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

That works perfectly. Thank you SO much!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown dependencies with multiple dropdowns Multiple entries in dropdown lists paul_pearson Word VBA 151 10-18-2023 04:23 PM
Dropdown dependencies with multiple dropdowns Multiple Selection Dropdown list ajanson Word VBA 36 07-15-2019 08:16 PM
Dropdown dependencies with multiple dropdowns Dropdown boxes to multiple fields? Nukedaddy Word 3 09-16-2016 06:50 AM
Dropdown dependencies with multiple dropdowns Content Control Dropdown Dependencies asteinroeder Word VBA 5 10-28-2015 03:56 PM
Multiple resource Dependencies / Mapping Sherry Project 3 04-03-2014 08:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:41 PM.


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