Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #31  
Old 05-11-2020, 11:23 PM
Guessed's Avatar
Guessed Guessed is offline Help with cascading dropdown list Windows 10 Help with cascading dropdown list Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 1,732
Guessed is a glorious beacon of lightGuessed is a glorious beacon of lightGuessed is a glorious beacon of lightGuessed is a glorious beacon of lightGuessed is a glorious beacon of lightGuessed is a glorious beacon of light
Default

Paul


The OP is alluding to the display of Content Controls which can have three possible views. This is configurable by editing the properties of a CC to choose a "Show As" setting. I'm not sure why they prefer the Start/End Tag option.

To change the appearance, add this line to the code after the .Type lines
.Appearance = wdContentControlTags
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #32  
Old 05-11-2020, 11:38 PM
macropod's Avatar
macropod macropod is offline Help with cascading dropdown list Windows 7 64bit Help with cascading dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,453
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

__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #33  
Old 07-08-2020, 05:02 PM
kevinbradley57 kevinbradley57 is offline Help with cascading dropdown list Windows 7 64bit Help with cascading dropdown list Office 2010 64bit
Advanced Beginner
 
Join Date: Jul 2017
Posts: 69
kevinbradley57 is on a distinguished road
Default StrOut syntax?

Since StrOut is comma delimited, what is the syntax needed to include a comma in my list item such as the below?
- bananas and grapes
- watermelon
- oranges, apples, and pears

Code:
      StrOut = "oranges, apples, and pears"

Last edited by kevinbradley57; 07-08-2020 at 05:24 PM. Reason: forgot code
Reply With Quote
  #34  
Old 07-08-2020, 05:15 PM
Guessed's Avatar
Guessed Guessed is offline Help with cascading dropdown list Windows 10 Help with cascading dropdown list Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 1,732
Guessed is a glorious beacon of lightGuessed is a glorious beacon of lightGuessed is a glorious beacon of lightGuessed is a glorious beacon of lightGuessed is a glorious beacon of lightGuessed is a glorious beacon of light
Default

kevin

The examples used a comma delimiter but you could use any (non-used) character you wanted as the separator. If you wanted to change to something else you could eg
Code:
StrOut = "bananas|watermelon|oranges, apples, and pears"
For i = 0 To UBound(Split(StrOut, "|"))
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #35  
Old 07-08-2020, 06:29 PM
gmaxey gmaxey is offline Help with cascading dropdown list Windows 10 Help with cascading dropdown list Office 2016
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 1,081
gmaxey has a spectacular aura aboutgmaxey has a spectacular aura aboutgmaxey has a spectacular aura about
Default

You could pass it to a funtion:
Code:
Sub TestATS()
Dim arrTest() As String
  arrTest = Split("A", "|")
  MsgBox fcnArrayToString(arrTest)
  arrTest = Split("A|B", "|")
  MsgBox fcnArrayToString(arrTest)
  arrTest = Split("A|B|C|D", "|")
  MsgBox fcnArrayToString(arrTest)
  MsgBox fcnArrayToString(arrTest, True)
End Sub

Public Function fcnArrayToString(varIn As Variant, Optional bOxford As Boolean = False) As String
Dim strTemp As String
Dim lngIndex As Long
  Select Case UBound(varIn)
    Case 0: fcnArrayToString = varIn(0)
    Case 1: fcnArrayToString = varIn(0) & " and " & varIn(1)
    Case Else
      fcnArrayToString = varIn(0)
      lngIndex = 1
      Do While lngIndex < UBound(varIn)
        fcnArrayToString = fcnArrayToString & ", " & varIn(lngIndex)
        lngIndex = lngIndex + 1
      Loop
      If bOxford Then
        fcnArrayToString = fcnArrayToString & ", and " & varIn(lngIndex)
      Else
        fcnArrayToString = fcnArrayToString & " and " & varIn(lngIndex)
      End If
  End Select
lbl_Exit:
  Exit Function
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #36  
Old 07-18-2020, 02:04 AM
markarius markarius is offline Help with cascading dropdown list Windows 10 Help with cascading dropdown list Office 2019
Novice
 
Join Date: May 2020
Posts: 4
markarius is on a distinguished road
Default

Hi again Macropod and others,

Thanks for all the feedback. I managed to get things working. I do need help with something else.

Basically, I have parent content control "Spouse" and "A&A" as child.
if spouse is Yes, then A&A has multiple selection options, but of the different options, IF either "spouse is able and available" or "spouse is able and partially available" then I need that value outputted somewhere in the document. Currently, I'm doing that in the form of dropdown. I would prefer a neater solution... preferable as text output when one of those 2 is selected in A&A. Would appreciate if you can reply with the code needed for this. Please post complete code so that I can copy/paste and replace the entire thing.

below is existing code in it's entirety:
Quote:
Option Explicit
Dim StrOption As String

Private Sub Document_ContentControlOnEnter(ByVal CCtrl As ContentControl)
With CCtrl
Select Case .Title
Case "Spouse", "A&A", "Minor": StrOption = .Range.Text
End Select
End With
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


' /// SPOUSE - ABLE & AVAILABLE
If .Title = "Spouse" Then
If StrOption = .Range.Text Then Exit Sub
Select Case .Range.Text
Case "Yes"
StrOut = "Spouse is able and available,Spouse is able and partially available,Spouse is able but not available,Spouse is available but not able,Spouse is IHSS Recipient,Other"
Case "No"
StrOut = "N/A"
Case "Recipient is not married"
StrOut = "N/A"
Case Else
.Type = wdContentControlText
.Appearance = wdContentControlTags
.Range.Text = ""
.Type = wdContentControlDropdownList
.Appearance = wdContentControlTags
End Select
With ActiveDocument.SelectContentControlsByTitle("A&A") (1)
.DropdownListEntries.Clear
For i = 0 To UBound(Split(StrOut, ","))
.DropdownListEntries.Add Split(StrOut, ",")(i)
Next
.Type = wdContentControlText
.Appearance = wdContentControlTags
.Range.Text = ""
.Type = wdContentControlDropdownList
.Appearance = wdContentControlTags
End With
End If



' /// SPOUSE - ALTERNATE RESOURCE
If .Title = "A&A" Then
If StrOption = .Range.Text Then Exit Sub
Select Case .Range.Text
Case "Spouse is able and available"
StrOut = "Spouse is able and available."

Case "Spouse is able and partially available"
StrOut = "Spouse is able and partially available."

Case Else
.Type = wdContentControlText
.Appearance = wdContentControlTags
.Range.Text = ""
.Type = wdContentControlDropdownList
.Appearance = wdContentControlTags
End Select
With ActiveDocument.SelectContentControlsByTitle("AltRe source-Spouse")(1)
.DropdownListEntries.Clear
For i = 0 To UBound(Split(StrOut, ","))
.DropdownListEntries.Add Split(StrOut, ",")(i)
Next
.Type = wdContentControlText
.Appearance = wdContentControlTags
.Range.Text = ""
.Type = wdContentControlDropdownList
.Appearance = wdContentControlTags
End With
End If


' /// MINOR
If .Title = "Minor" Then
If StrOption = .Range.Text Then Exit Sub
Select Case .Range.Text
Case "Yes", "Recipient is not a minor"
StrOut = "N/A"
Case "Recipient is not a minor"
StrOut = "N/A"
Case "No"
StrOut = "Parent is prevented from full-time employment due to child's needs,Recipient is under the care of a Legal Guardian"
Case Else
.Type = wdContentControlText
.Range.Text = ""
.Type = wdContentControlDropdownList
End Select
With ActiveDocument.SelectContentControlsByTitle("Minor Exp")(1)
.DropdownListEntries.Clear
For i = 0 To UBound(Split(StrOut, ","))
.DropdownListEntries.Add Split(StrOut, ",")(i)
Next
.Type = wdContentControlText
.Range.Text = ""
.Type = wdContentControlDropdownList
End With
End If



End With
Application.ScreenUpdating = True
End Sub
Reply With Quote
  #37  
Old 07-18-2020, 02:15 AM
markarius markarius is offline Help with cascading dropdown list Windows 10 Help with cascading dropdown list Office 2019
Novice
 
Join Date: May 2020
Posts: 4
markarius is on a distinguished road
Default Content Control as combobox instead of dropbox

Hi

I need help with a small issue in my code.
Basically, the code has parent dropbox "Lives with", and if user selects "recipient lives alone" then it currently limits child dropbox (Occupants) to "N/A"
but if user selects "Recipient shares home" I would like for it to output a value, but for that box to be a combo box and not a dropbox, meaning that user can edit the output values instead of locked field. I would appreciate all the help I can get on this. Thanks!



Quote:
' /// RECIPIENT LIVES WITH OTHERS - OTHER OCCUPANTS
' note: lives alone = N/A (ok), but lives with other needs to allow custom text but DB is locked.
' reminder: once code is ready add "Lives with" to Document_ContentControlOnEnter
If .Title = "Lives with" Then
If StrOption = .Range.Text Then Exit Sub
Select Case .Range.Text
Case "Recipient lives alone"
StrOut = "N/A"
Case "Recipient shares home"
StrOut = "Occupant1; Occupant2" ' << need this to be editable.
Case Else
.Type = wdContentControlText
.Range.Text = ""
.Type = wdContentControlComboBox
End Select
With ActiveDocument.SelectContentControlsByTitle("Occup ants")(1)
.DropdownListEntries.Clear
For i = 0 To UBound(Split(StrOut, ","))
.DropdownListEntries.Add Split(StrOut, ",")(i)
Next
.Type = wdContentControlText
.Range.Text = ""
.Type = wdContentControlDropdownList
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown list, Macro shield5 Excel Programming 7 10-27-2013 01:51 AM
VBA: How to place dropdown list next to text YigalB Word VBA 0 08-11-2013 01:48 PM
block selection in dropdown list Intruder Excel 2 01-10-2013 10:20 AM
Help with cascading dropdown list dropdown list for documents r_p_t_0 Word 2 12-18-2012 05:55 AM
Dropdown list of email addresses J Partridge Outlook 1 01-13-2011 06:37 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 01:35 PM.


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