Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 03-27-2020, 12:41 PM
mrstrawhand mrstrawhand is offline Cascading drop-downs in Word with one parent menu and four dependent drop-downs Windows 8 Cascading drop-downs in Word with one parent menu and four dependent drop-downs Office 2013
Novice
Cascading drop-downs in Word with one parent menu and four dependent drop-downs
 
Join Date: Mar 2020
Posts: 2
mrstrawhand is on a distinguished road
Default Cascading drop-downs in Word with one parent menu and four dependent drop-downs


Hello!

I am trying to create cascading drop-down menus in Word, and I have never done those before. In doing some research, I have adapted code, but I am getting an error message and then the drop downs are not dependent. I am not sure how to fix the code so that it works for the one parent menu and the four dependent menus. The error I get is "Compile error: Expected End With" and here is the code I currently have (with the data updated to be generic):
Code:
Option Explicit
Dim StrOption As String
Private Sub Document_ContentControlOnEnter(ByVal CCtrl As ContentControl)
If CCtrl.Title = "ProductServices" Then StrOption = CCtrl.Range.Text
If CCtrl.Title = "Unit" Then 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 = "ProductServices" Then
    If StrOption = .Range.Text Then Exit Sub
    Select Case .Range.Text
      Case "1"
        StrOut = "Per Hotel Vendor Chain"
      Case "2"
        StrOut = "Per Hotel Vendor Chain"
      Case "3"
        StrOut = "Per Hotel Vendor Chain"
      Case "4"
        StrOut = "Per Hotel Vendor Chain"
      Case "5"
        StrOut = "Per Hotel Vendor Chain"
      Case "6"
        StrOut = "Per Hotel Vendor Chain"
      Case "7"
        StrOut = "Per Hotel Vendor Chain"
      Case "8"
        StrOut = "Per Hotel Vendor Chain"
      Case "9"
        StrOut = "Per Property / per core"
      Case "10"
        StrOut = "Per Hotel Vendor Chain"
      Case "11"
        StrOut = "Per Hotel Vendor Chain"
      Case "12"
        StrOut = "Per Hotel Vendor Chain"
      Case "13"
        StrOut = "Per Hotel Vendor Chain"
      Case "14"
        StrOut = "Per Hotel Vendor Chain"
      Case "15"
        StrOut = "Per Hotel Vendor Chain"
      Case "16"
        StrOut = "Per Hotel Vendor Chain"
      Case "17"
        StrOut = "Per Hotel Vendor Chain"
      Case "18"
        StrOut = "Per Hotel Vendor Chain"
      Case "19"
        StrOut = "Per License"
        StrOut = "N/A"
      Case "20"
        StrOut = "Per License"
        StrOut = "N/A"
      Case "21"
        StrOut = "Per License"
        StrOut = "N/A"
      Case "22"
        StrOut = "N/A"
      Case "23"
        StrOut = "N/A"
      Case "24"
        StrOut = "Per License"
      Case "25"
        StrOut = "Per License"
      Case "26"
        StrOut = "Per Hotel Vendor Chain"
      Case Else
        .Type = wdContentControlText
        .Range.Text = ""
        .Type = wdContentControlDropdownList
    End Select
    With ActiveDocument.SelectContentControlsByTitle("Unit")(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("Recurringfee")(1)
      .DropdownListEntries.Clear
      .Type = wdContentControlText
      .Range.Text = ""
      .Type = wdContentControlDropdownList
    End With
  End If
  If .Title = "ProductService" Then
    If StrOption = .Range.Text Then Exit Sub
    Select Case .Range.Text
       Case "1"
        StrOut = "N/A"
      Case "2"
        StrOut = "N/A"
      Case "3"
        StrOut = "N/A"
      Case "4"
        StrOut = "N/A"
      Case "5"
        StrOut = "N/A"
      Case "6"
        StrOut = "N/A"
      Case "7"
        StrOut = "N/A"
      Case "8"
        StrOut = "$10.00"
      Case "9"
        StrOut = "$25.00"
      Case "10"
        StrOut = "$100.00"
      Case "11"
        StrOut = "N/A"
      Case "12"
        StrOut = "N/A"
      Case "13"
        StrOut = "N/A"
      Case "14"
        StrOut = "N/A"
      Case "15"
        StrOut = "N/A"
      Case "16"
        StrOut = "N/A"
      Case "17"
        StrOut = "N/A"
      Case "18"
        StrOut = "N/A"
      Case "19"
        StrOut = "$10.00"
      Case "20"
        StrOut = "$180.00"
      Case "21"
        StrOut = "$60.00"
      Case "22"
        StrOut = "$30.00"
      Case "23"
        StrOut = "$48.00"
      Case "24"
        StrOut = "N/A"
      Case "25"
        StrOut = "N/A"
      Case "26"
        StrOut = "N/A"
      Case Else
        .Type = wdContentControlText
        .Range.Text = ""
        .Type = wdContentControlDropdownList
    End Select
    With ActiveDocument.SelectContentControlsByTitle("Recurringfee")(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 = "ProductService" Then
    If StrOption = .Range.Text Then Exit Sub
    Select Case .Range.Text
       Case "1"
        StrOut = "$20,000.00"
      Case "2"
        StrOut = "$15,000.00"
      Case "3"
        StrOut = "$17,500.00"
      Case "4"
        StrOut = "$10,000.00"
      Case "5"
        StrOut = "$10,000.00"
      Case "6"
        StrOut = "$1,000.00"
      Case "7"
        StrOut = "$1,000.00"
      Case "8"
        StrOut = "N/A"
      Case "9"
        StrOut = "N/A"
      Case "10"
        StrOut = "N/A"
      Case "11"
        StrOut = "$2,000.00"
      Case "12"
        StrOut = "$500.00"
      Case "13"
        StrOut = "$2,000.00"
      Case "14"
        StrOut = "$2,000.00"
      Case "15"
        StrOut = "$5,000.00"
      Case "16"
        StrOut = "$5,000.00"
      Case "17"
        StrOut = "$2,000.00"
      Case "18"
        StrOut = "$2,000.00"
      Case "19"
        StrOut = "$200.00"
      Case "20"
        StrOut = "$200.00"
      Case "21"
        StrOut = "$200.00"
      Case "22"
        StrOut = "N/A"
      Case "23"
        StrOut = "N/A"
      Case "24"
        StrOut = "$3,000.00"
      Case "25"
        StrOut = "$1,000.00"
      Case "26"
        StrOut = "$500.00"
      Case Else
        .Type = wdContentControlText
        .Range.Text = ""
        .Type = wdContentControlDropdownList
    End Select
    With ActiveDocument.SelectContentControlsByTitle("Onetimefee")(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 = "ProductService" Then
    If StrOption = .Range.Text Then Exit Sub
    Select Case .Range.Text
       Case "1"
        StrOut = "One-time"
      Case "2"
        StrOut = "One-time"
      Case "3"
        StrOut = "One-time"
      Case "4"
        StrOut = "One-time"
      Case "5"
        StrOut = "One-time"
      Case "6"
        StrOut = "One-time"
      Case "7"
        StrOut = "One-time"
      Case "8"
        StrOut = "Monthly"
      Case "9"
        StrOut = "Monthly"
      Case "10"
        StrOut = "Monthly"
      Case "11"
        StrOut = "One-time"
      Case "12"
        StrOut = "One-time"
      Case "13"
        StrOut = "One-time"
      Case "14"
        StrOut = "One-time"
      Case "15"
        StrOut = "One-time"
      Case "16"
        StrOut = "One-time"
      Case "17"
        StrOut = "One-time"
      Case "18"
        StrOut = "One-time"
      Case "19"
        StrOut = "Monthly for Recurring Fee; One-time for One-time Fee"
      Case "20"
        StrOut = "Monthly for Recurring Fee; One-time for One-time Fee"
      Case "21"
        StrOut = "Monthly for Recurring Fee; One-time for One-time Fee"
      Case "22"
        StrOut = "Monthly"
      Case "23"
        StrOut = "Monthly"
      Case "24"
        StrOut = "One-time"
      Case "25"
        StrOut = "One-time"
      Case "26"
        StrOut = "One-time"
      Case Else
        .Type = wdContentControlText
        .Range.Text = ""
        .Type = wdContentControlDropdownList
    End Select
    With ActiveDocument.SelectContentControlsByTitle("Billingmode")(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
Application.ScreenUpdating = True
End Sub
Any assistance or guidance would be appreciated!

Last edited by macropod; 03-27-2020 at 02:30 PM. Reason: Added code tags
  #2  
Old 03-27-2020, 02:31 PM
macropod's Avatar
macropod macropod is offline Cascading drop-downs in Word with one parent menu and four dependent drop-downs Windows 7 64bit Cascading drop-downs in Word with one parent menu and four dependent drop-downs Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,346
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Cross-posted at: Cascading drop-downs in Word - Microsoft Community
For cross-posting etiquette, please read: Excelguru Help Site - A message to forum cross posters
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
  #3  
Old 03-27-2020, 02:39 PM
mrstrawhand mrstrawhand is offline Cascading drop-downs in Word with one parent menu and four dependent drop-downs Windows 8 Cascading drop-downs in Word with one parent menu and four dependent drop-downs Office 2013
Novice
Cascading drop-downs in Word with one parent menu and four dependent drop-downs
 
Join Date: Mar 2020
Posts: 2
mrstrawhand is on a distinguished road
Default

Thanks for making me aware of this! I marked this post as 'solved' since someone commented on the other. I'm not sure how to delete a thread from here!
  #4  
Old 03-30-2020, 06:08 AM
Charles Kenyon Charles Kenyon is offline Cascading drop-downs in Word with one parent menu and four dependent drop-downs Windows 10 Cascading drop-downs in Word with one parent menu and four dependent drop-downs Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 6,535
Charles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to behold
Default

We might as well leave it up here so that anyone finding this thread will have a link to the solution.
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cascading drop-downs in Word with one parent menu and four dependent drop-downs Needing to learn dependent drop downs and how to still keep the document editable sconeill92 Word VBA 12 02-21-2020 10:16 AM
Cascading drop-downs in Word with one parent menu and four dependent drop-downs Help with Colour Coding drop downs. Instructionalhelp Word VBA 11 03-15-2018 10:35 PM
Cascading drop-downs in Word with one parent menu and four dependent drop-downs Lock specific drop downs on a Word Document icarrus Word 1 09-30-2015 02:07 PM
Drop Downs Suray1911 Excel 1 09-29-2015 10:31 PM
Cascading drop-downs in Word with one parent menu and four dependent drop-downs Drop-Downs: Run Macro on Exit Andrew H Word VBA 15 11-16-2012 08:34 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 04:59 AM.


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