View Single Post
 
Old 07-18-2023, 05:43 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

For someone who is 'kinda new to macros' and speaks multiple languages you have done a remarkable job with the code. Well done.

However you haven't explained particularly well your actual question with regards to a third level. You also didn't post a sample document so we can't see what your structure might be for that third level.

I've looked at the code you provided and decided that it is needlessly repetitive and can be streamlined to make things clearer. So I created a sample doc and set up some loops to achieve what I think your code was already doing in a less repetitive way. This makes use of both the Title and Tag properties of the CCs so that groups of related CCs can be looped through in the code. If this aligns with your actual document, then perhaps you can post a sample document and explain more clearly what the third level should do when the second level is changed.

I suspect it can be even more streamlined if your document is setup with Repeating Sections which is what it appears you are trying to do.

This is the code I adapted from your posted code so that it works with a document with CCs set up with both Tag and Title attributes.
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
  Application.ScreenUpdating = False
  Dim i As Long, StrOut As String, aCC As ContentControl, arrOut() As String
  With CCtrl
    If .Tag = "Trigger" Then
      If StrOption = .Range.Text Then Exit Sub
      Select Case .Range.Text
        Case "Se comunica oralmente en inglés como lengua extranjera"
          StrOut = "Obtiene información de textos orales;Infiere e interpreta información de textos orales;Adecúa, organiza y desarrolla las ideas de forma coherente y cohesionada;Utiliza recursos no verbales y paraverbales de forma estratégica;Interactúa estratégicamente con distintos interlocutores;Reflexiona y evalúa la forma, el contenido y el contexto del texto oral"
        Case "Lee diversos tipos de textos en inglés como lengua extranjera"
          StrOut = "Obtiene información del texto escrito;Infiere e interpreta información del texto escrito;Reflexiona y evalúa la forma, el contenido y contexto del texto"
        Case "Escribe diversos tipos de textos en inglés como lengua extranjera"
          StrOut = "Adecúa el texto a la situación comunicativa;Organiza y desarrolla las ideas de forma coherente y cohesionada;Utiliza convenciones del lenguaje escrito de forma pertinente;Reflexiona y evalúa la forma, el contenido y contexto del texto escrito"
        Case Else
          .Type = wdContentControlText
          .Range.Text = ""
          .Type = wdContentControlDropdownList
      End Select
      arrOut = Split(StrOut, ";")
      For Each aCC In ActiveDocument.SelectContentControlsByTag(CCtrl.Title)
        aCC.DropdownListEntries.Clear
        aCC.DropdownListEntries.Add .PlaceholderText
        aCC.Type = wdContentControlText
          aCC.Range.Text = ""
        aCC.Type = wdContentControlDropdownList
        If Not CCtrl.ShowingPlaceholderText Then
          For i = 0 To UBound(arrOut)
            aCC.DropdownListEntries.Add arrOut(i)
          Next
        End If
      Next aCC
    End If
  End With
  Application.ScreenUpdating = True
End Sub
Attached Files
File Type: docm DependentCCs.docm (37.4 KB, 9 views)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote