|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Lock or unlock a content control depending on the selection from the drop down list
I am making a template in Word and I need to lock or unlock a content control depending on the selection made in a drop-down list, for example if in the drop-down list Disk is selected, unlock the content controls disk_unit and amount_space for its value to be entered, but if in the drop-down list they select Memory, lock the disk_unit and amount_space content controls, and unlock the amount_memory content control so that its value is entered |
#2
|
||||
|
||||
If you post a sample document with the CCs in it, we can create the specific macro but the principle is shown in other threads here.
For instance you could adapt Macropod's code in this post without needing to recreate the wheel. https://www.msofficeforums.com/128781-post4.html
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Lock or unlock a content control depending on the selection from the drop down list
Thanks for your answer.
I am attaching the example word format that I am using. What I need is to block or unblock a content control according to the selection made in the drop-down list "TIncremento"(Tipo de Incremento), for example, if in the drop-down list Disco or filesystems is selected, the content controls "lunidad" and "espacio" are unlocked (to provide that information) and the content control "memoria" is locked; but if in the drop-down list they select Memoria or CPU/SLICES, the content controls "lunidad:" and "espacio" are locked, and the content control "memoria" is unlocked (so that they enter their value). Hopefully you can help me ... Thanks |
#4
|
||||
|
||||
OK, firstly get rid of the legacy form field you were using for the Tipo de Incremento and instead put a Dropdown List Content Control in its place, set its Title property to TIncremento and add the four options.
Then add this code to your ThisDocument module Code:
Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean) Dim i As Long, bOne As Boolean With aCC If .Title = "TIncremento" Then Select Case LCase(.Range.Text) Case "disco", "filesystem" bOne = True Case "memoria", "cpu/slices" bOne = False End Select LockCC ActiveDocument.SelectContentControlsByTitle("lunidad")(1), Not bOne LockCC ActiveDocument.SelectContentControlsByTitle("espacio")(1), Not bOne LockCC ActiveDocument.SelectContentControlsByTitle("memoria")(1), bOne End If End With End Sub Function LockCC(aCC As ContentControl, bLock As Boolean) With aCC aCC.LockContents = False If bLock Then aCC.Range.Text = "" .Color = wdColorGray50 Else .Color = wdColorYellow End If aCC.LockContents = bLock End With End Function
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
OK, thank you very much, I will make the changes that you indicate, I thank you very much
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Assigning Macro to Drop Down list Content Control | aussiew | Word VBA | 5 | 03-10-2019 02:55 PM |
How to unlock header content control in form | Nikko963 | Word VBA | 6 | 04-13-2018 03:08 PM |
How to get a Drop Down List Content Control box to fill in other areas | snips1982 | Word | 2 | 03-22-2017 03:37 AM |
How do I add selection of multi line content control list to specific table cell | Dudlee | Word VBA | 1 | 09-20-2016 04:58 PM |
Word 2010 Content Control help - Combo Boxes vs Drop Down List | proghy | Word | 1 | 09-16-2014 02:01 PM |