Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-04-2021, 10:09 AM
ncruz ncruz is offline Lock or unlock a content control depending on the selection from the drop down list Windows 10 Lock or unlock a content control depending on the selection from the drop down list Office 2016
Novice
Lock or unlock a content control depending on the selection from the drop down list
 
Join Date: May 2021
Posts: 3
ncruz is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 10-04-2021, 05:43 PM
Guessed's Avatar
Guessed Guessed is offline Lock or unlock a content control depending on the selection from the drop down list Windows 10 Lock or unlock a content control depending on the selection from the drop down list Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 2,724
Guessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to behold
Default

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
Reply With Quote
  #3  
Old 10-06-2021, 01:42 PM
ncruz ncruz is offline Lock or unlock a content control depending on the selection from the drop down list Windows 10 Lock or unlock a content control depending on the selection from the drop down list Office 2016
Novice
Lock or unlock a content control depending on the selection from the drop down list
 
Join Date: May 2021
Posts: 3
ncruz is on a distinguished road
Default 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
Attached Files
File Type: docm EjemploFormato.docm (42.7 KB, 2 views)
Reply With Quote
  #4  
Old 10-06-2021, 08:35 PM
Guessed's Avatar
Guessed Guessed is offline Lock or unlock a content control depending on the selection from the drop down list Windows 10 Lock or unlock a content control depending on the selection from the drop down list Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 2,724
Guessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to behold
Default

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
Reply With Quote
  #5  
Old 10-15-2021, 08:50 AM
ncruz ncruz is offline Lock or unlock a content control depending on the selection from the drop down list Windows 10 Lock or unlock a content control depending on the selection from the drop down list Office 2016
Novice
Lock or unlock a content control depending on the selection from the drop down list
 
Join Date: May 2021
Posts: 3
ncruz is on a distinguished road
Default

OK, thank you very much, I will make the changes that you indicate, I thank you very much
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lock or unlock a content control depending on the selection from the drop down list 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
Lock or unlock a content control depending on the selection from the drop down list How to get a Drop Down List Content Control box to fill in other areas snips1982 Word 2 03-22-2017 03:37 AM
Lock or unlock a content control depending on the selection from the drop down list 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

Other Forums: Access Forums

All times are GMT -7. The time now is 07:45 AM.


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