Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-21-2018, 08:04 AM
and23 and23 is offline Cascading Drop Down Windows Vista Cascading Drop Down Office 2013
Novice
Cascading Drop Down
 
Join Date: May 2018
Posts: 5
and23 is on a distinguished road
Default Cascading Drop Down


I want to make a cascading drop down that if N/A is selected on drop down 1 then the next two drop downs will auto-populate with N/A and be non-editable.
Reply With Quote
  #2  
Old 05-21-2018, 02:48 PM
macropod's Avatar
macropod macropod is offline Cascading Drop Down Windows 7 64bit Cascading Drop Down Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

What kind of dropdown?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-22-2018, 05:23 AM
and23 and23 is offline Cascading Drop Down Windows Vista Cascading Drop Down Office 2013
Novice
Cascading Drop Down
 
Join Date: May 2018
Posts: 5
and23 is on a distinguished road
Cool

I'm using the Drop Down List Content Control in Developer.

I wouldn't mind doing it an alternative way if possible.
Reply With Quote
  #4  
Old 05-22-2018, 03:45 PM
macropod's Avatar
macropod macropod is offline Cascading Drop Down Windows 7 64bit Cascading Drop Down Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could use a ContentControlOnExit macro in the 'ThisDocument' code module of the document or its template, coded like:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Dim i As Long
With CCtrl
  If .Title = "Master" Then
    If .Range.Text = "N/A" Then
      For i = 1 To 2
        With ActiveDocument.SelectContentControlsByTitle("Slave")(i)
          .Type = wdContentControlText
          .Range.Text = "N/A"
          .LockContents = True
        End With
      Next
    Else
      For i = 1 To 2
        With ActiveDocument.SelectContentControlsByTitle("Slave")(i)
          If .Type = wdContentControlText Then
            .LockContents = False
            .Range.Text = ""
            .Type = wdContentControlDropdownList
          End If
        End With
      Next
    End If
  End If
End With
End Sub
In the above code, the controlling content control is titled 'Master' and the two dependent content controls are titled 'Slave'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-22-2018, 08:30 PM
and23 and23 is offline Cascading Drop Down Windows Vista Cascading Drop Down Office 2013
Novice
Cascading Drop Down
 
Join Date: May 2018
Posts: 5
and23 is on a distinguished road
Red face

Thank you. That worked, but it gives me an error stating "Run-time error '6124': You are not allowed to edit this selection because it is protected." whenever I click out of the Master Content Control Drop Down.

Sorry for the inconvenience, I'm new with VBA so don't really know much about it.

Thanks!
Reply With Quote
  #6  
Old 05-22-2018, 08:33 PM
and23 and23 is offline Cascading Drop Down Windows Vista Cascading Drop Down Office 2013
Novice
Cascading Drop Down
 
Join Date: May 2018
Posts: 5
and23 is on a distinguished road
Red face

Another issue is that when I select another option (in my case the word "test") after I choose N/A it does not become re-editable is that an extra step?
Reply With Quote
  #7  
Old 05-23-2018, 02:24 AM
macropod's Avatar
macropod macropod is offline Cascading Drop Down Windows 7 64bit Cascading Drop Down Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Unless you've misnamed your master, the slaves alone should lock/unlock. Without seeing your document, though, I can't investigate the issue.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 05-23-2018, 06:05 AM
and23 and23 is offline Cascading Drop Down Windows Vista Cascading Drop Down Office 2013
Novice
Cascading Drop Down
 
Join Date: May 2018
Posts: 5
and23 is on a distinguished road
Talking

See attached. It seems like it doesn't give that error anymore, but it still doesn't unlock.
Thanks!
Attached Files
File Type: docx N.docx (20.5 KB, 9 views)
Reply With Quote
  #9  
Old 05-23-2018, 02:33 PM
macropod's Avatar
macropod macropod is offline Cascading Drop Down Windows 7 64bit Cascading Drop Down Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your attachment is in the docx format, so it can't contain the ContentControlOnExit macro. Unless you added the ContentControlOnExit macro to the 'ThisDocument' code module of the document's template, therefore, you would lose its functionality as soon as you close the document. If you don' want to do that, you'll need to save the document in the docm format (i.e. as a macro-enabled document), with the ContentControlOnExit macro to the 'ThisDocument' code module of the document itself.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cascading Drop Down Help with cascading dropdown list SaraO Word VBA 45 02-05-2023 05:33 PM
Userform with Multiple Cascading Drop Down Lists Populated with External Source Data venganewt Word VBA 21 05-16-2018 02:05 PM
Cascading Drop Down Cascading List Word 2010 Marvel Word VBA 11 05-14-2016 02:08 AM
Cascading Drop Down Issue Using Word Document with Cascading Drop Down Lists LynnMac2016 Word VBA 3 04-06-2016 06:15 AM
Cascading Drop Down How to update cascading styles? mmmb Word 3 01-21-2016 07:08 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:29 AM.


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