Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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: 4,159
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

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
 



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 02:19 PM.


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