#136
|
||||
|
||||
See post #71 in this thread: https://www.msofficeforums.com/word-...tml#post120392
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#137
|
|||
|
|||
Everything works so far, if I only use one table row. However, when I duplicate the row using ContentControl, the macros get messed up and they start to fill out the wrong fields in the wrong rows. Does anyone have an idea, how to fix this?
|
#138
|
||||
|
||||
There are 136 previous posts in this thread and I have no idea on what you are looking at. I suggest you start a new thread and post your document so someone can look at what your issue might be.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#139
|
|||
|
|||
Hi Macropod, thanks for this. when i am recreating this code on a different word file, i am getting an error on this line .
ActiveDocument.ContentControls(2).Range.Text = StrDetails I basically copied same code changed the Title to reflect my new title which is "Office". What am i missing? Appreciate your help Full Code here: Code:
Option Explicit Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim i As Long, StrDetails As String With ContentControl If .Title = "Office" 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 Last edited by macropod; 04-29-2022 at 06:23 PM. Reason: Added code tags |
#140
|
||||
|
||||
The output goes to the second content control in the document, which must be a Rich Text content control. Is that how your document is configured?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#141
|
|||
|
|||
Hi,
I am new to Macros.. I was able to change the drop down items to and its result. But I would like to change the First Content Control titles from "Client Details" to "Please Select" and the second Content Control Title from "Client" to "Blank" I have tried to change in the properties and in the code too but it gives me Run Time Error "6189" Also I would like to result to be in other place not close to drop down menu. Is it possible. Thanks |
#142
|
||||
|
||||
Quote:
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#143
|
|||
|
|||
Please ignore my post. I have found answer in another post of yours. My answer was formfield
Quote:
Last edited by bil_san1; 10-12-2022 at 02:55 AM. Reason: Found the answer in another post |
#144
|
|||
|
|||
Paul,
This is a very long thread. Perhaps I've shared this with you before but not sure. Have you considered mapping the two controls in your example file (post #2). If you do, your code is reduced to: Code:
Private Sub Document_ContentControlBeforeContentUpdate(ByVal ContentControl As ContentControl, Content As String) With ContentControl If .Title = "Client" Then .XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:ClientDetails[1]").Text = _ Replace(.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Client[1]").Text, "|", vbCr) End If End With lbl_Exit: Exit Sub End Sub with no requirement to exit the Client CC |
#145
|
|||
|
|||
Hi, I'm kinda new to macros on word. So, I managed to do a two-level dependent dropdown list with contentcontrol boxes. I want to make third level but this one is autopopulated. I saw the method with values, but because it's a dependent dropdown list there are no values for the second level. I've looked through all posts on this thread but it seems there's no answer for what I need.
I would really be thankful if someone can help me. This is the code I've got so far, what I want is that after I select the second dropdown another control content box gets filled on its own with a set value. Let's say I select Quote:
Code:
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" Code:
Option Explicit Dim StrOption As String Private Sub Document_ContentControlOnEnter(ByVal CCtrl As ContentControl) StrOption = CCtrl.Range.Text End Sub Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean) Application.ScreenUpdating = False Dim i As Long, StrOut As String With CCtrl If .Title = "Competencias" 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 With ActiveDocument.SelectContentControlsByTitle("Capacidades")(1) .DropdownListEntries.Clear .DropdownListEntries.Add .PlaceholderText For i = 0 To UBound(Split(StrOut, ";")) .DropdownListEntries.Add Split(StrOut, ";")(i) Next .Type = wdContentControlText .Range.Text = "" .Type = wdContentControlDropdownList End With With ActiveDocument.SelectContentControlsByTitle("Capacidades2")(1) .DropdownListEntries.Clear .DropdownListEntries.Add .PlaceholderText For i = 0 To UBound(Split(StrOut, ";")) .DropdownListEntries.Add Split(StrOut, ";")(i) Next .Type = wdContentControlText .Range.Text = "" .Type = wdContentControlDropdownList End With With ActiveDocument.SelectContentControlsByTitle("Capacidades3")(1) .DropdownListEntries.Clear .DropdownListEntries.Add .PlaceholderText For i = 0 To UBound(Split(StrOut, ";")) .DropdownListEntries.Add Split(StrOut, ";")(i) Next .Type = wdContentControlText .Range.Text = "" .Type = wdContentControlDropdownList End With With ActiveDocument.SelectContentControlsByTitle("Capacidades4")(1) .DropdownListEntries.Clear .DropdownListEntries.Add .PlaceholderText For i = 0 To UBound(Split(StrOut, ";")) .DropdownListEntries.Add Split(StrOut, ";")(i) Next .Type = wdContentControlText .Range.Text = "" .Type = wdContentControlDropdownList End With End If If .Title = "Competencias2" 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 With ActiveDocument.SelectContentControlsByTitle("Capacidades5")(1) .DropdownListEntries.Clear .DropdownListEntries.Add .PlaceholderText For i = 0 To UBound(Split(StrOut, ";")) .DropdownListEntries.Add Split(StrOut, ";")(i) Next .Type = wdContentControlText .Range.Text = "" .Type = wdContentControlDropdownList End With With ActiveDocument.SelectContentControlsByTitle("Capacidades6")(1) .DropdownListEntries.Clear .DropdownListEntries.Add .PlaceholderText For i = 0 To UBound(Split(StrOut, ";")) .DropdownListEntries.Add Split(StrOut, ";")(i) Next .Type = wdContentControlText .Range.Text = "" .Type = wdContentControlDropdownList End With With ActiveDocument.SelectContentControlsByTitle("Capacidades7")(1) .DropdownListEntries.Clear .DropdownListEntries.Add .PlaceholderText For i = 0 To UBound(Split(StrOut, ";")) .DropdownListEntries.Add Split(StrOut, ";")(i) Next .Type = wdContentControlText .Range.Text = "" .Type = wdContentControlDropdownList End With With ActiveDocument.SelectContentControlsByTitle("Capacidades8")(1) .DropdownListEntries.Clear .DropdownListEntries.Add .PlaceholderText For i = 0 To UBound(Split(StrOut, ";")) .DropdownListEntries.Add Split(StrOut, ";")(i) Next .Type = wdContentControlText .Range.Text = "" .Type = wdContentControlDropdownList End With End If End With Application.ScreenUpdating = True End Sub |
#146
|
||||
|
||||
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
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#147
|
|||
|
|||
Thank you so much! This is a lot less than before, I totally forgot about OR XD.
Anyways, the third level is supposed to not give me an option, each contentbox of the second level has another control box and depending on which option I choose from the second level, it has to return an established text for just one box. I will upload my document with the updated code. Just a thing I noticed, the document you sent works fine, but mine doesn't, if I select "Se comunica oralmente" in the first level then the second level for both sets show me the second level just for that option, but if I choose any other it works just fine. I even copied the same boxes from your document and the code and nothing. |
#148
|
|||
|
|||
See attached
|
#149
|
|||
|
|||
Thank you for the document, now the second level works fine, but the third doesn't.
As I said, I want to automatically populate the third level depending on what I chose in the second one. Still, thank you a lot. I will upload it again and see what else can be done |
#150
|
|||
|
|||
See attached
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |