Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-27-2015, 03:13 PM
asteinroeder asteinroeder is offline Content Control Dropdown Dependencies Windows 8 Content Control Dropdown Dependencies Office 2013
Novice
Content Control Dropdown Dependencies
 
Join Date: Oct 2015
Posts: 3
asteinroeder is on a distinguished road
Default Content Control Dropdown Dependencies


Hi Paul,

I have used the macro that you supplied in https://www.msofficeforums.com/word-...own-lists.html and it works great. Is there a way to use the same macro except make it so depending on what I select from the dropdown menu, the output content can fill a row in a table in word? Instead of separating with a line break "|", is there a way to include a separator to acknowledge the cells and place values into different cells in a row?

Thank you for your help
Reply With Quote
  #2  
Old 10-27-2015, 03:29 PM
macropod's Avatar
macropod macropod is offline Content Control Dropdown Dependencies Windows 7 64bit Content Control Dropdown Dependencies 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

The value stored in the dropdown requires some form of separator to delineate the items. It's up to you what separator you use, but no separator will of itself tell Word to put something into a cell - you code has to do that. For example:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, StrDetails As String
With ContentControl
  If .Title = "Client" Then
    For i = 1 To .DropdownListEntries.Count
      If .DropdownListEntries(i).Text = .Range.Text Then
        StrDetails = .DropdownListEntries(i).Value
        Exit For
      End If
    Next
    With ActiveDocument.Tables(1).Rows(2)
      For i = 0 To UBound(Split(StrDetails, "|"))
        .Cells(i + 1).Range.Text = Split(StrDetails, "|")(i)
      Next
    End With
  End If
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-28-2015, 10:07 AM
asteinroeder asteinroeder is offline Content Control Dropdown Dependencies Windows 8 Content Control Dropdown Dependencies Office 2013
Novice
Content Control Dropdown Dependencies
 
Join Date: Oct 2015
Posts: 3
asteinroeder is on a distinguished road
Default

Thanks a lot for your help. I now have it working. My last question is whether I can get certain values of the output to go into different rows. Using the example that was previously used on this thread, if I wanted the Phone number to go into one row and then the Address to go into the next row. I know I could do this by creating multiple drop down menus that reference different rows, but is there a way to do it with one dropdown list?
Reply With Quote
  #4  
Old 10-28-2015, 01:11 PM
macropod's Avatar
macropod macropod is offline Content Control Dropdown Dependencies Windows 7 64bit Content Control Dropdown Dependencies 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

Pretty much anything is possible, but I have no idea what your actual requirements are vis-à-vis what cells you want to update. The code I posted is for populating a single row. Code for populating a single column is no more difficult; it's only when you want a mix of rows & columns that things might get complicated.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-28-2015, 03:31 PM
asteinroeder asteinroeder is offline Content Control Dropdown Dependencies Windows 8 Content Control Dropdown Dependencies Office 2013
Novice
Content Control Dropdown Dependencies
 
Join Date: Oct 2015
Posts: 3
asteinroeder is on a distinguished road
Default

To be more specific, based on the dropdown at the top for the category someone selects, it should populate table 5, row 3 in my document with the first 5 values of the category's output content, then it should populate table 5, row 4 with the next 5 values of the output, and finally table 5, row 5 with the last 5 values of the output. These 3 different rows have different sets of information (one row is currency, another is numbers, the other text) but it is all based on what the user initially selects from the dropdown.

So I am trying to list all 15 of the values in the drop-down list properties and have it read to row 3 and then wrap around to row 4 and then row 5. There might be a better way of having each row call on the dropdown, but this way would still work.

I hope that is more clear. Thank you.
Reply With Quote
  #6  
Old 10-28-2015, 03:56 PM
macropod's Avatar
macropod macropod is offline Content Control Dropdown Dependencies Windows 7 64bit Content Control Dropdown Dependencies 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

If your table has 5 columns throughout, you could use:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, StrDetails As String
With ContentControl
  If .Title = "Client" Then
    For i = 1 To .DropdownListEntries.Count
      If .DropdownListEntries(i).Text = .Range.Text Then
        StrDetails = .DropdownListEntries(i).Value
        Exit For
      End If
    Next
    With ActiveDocument.Tables(5).Range
      For i = 0 To 14
        .Cells(i + 11).Range.Text = Split(StrDetails, "|")(i)
      Next
    End With
  End If
End With
End Sub
Otherwise, you could use:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, StrDetails As String
With ContentControl
  If .Title = "Client" Then
    For i = 1 To .DropdownListEntries.Count
      If .DropdownListEntries(i).Text = .Range.Text Then
        StrDetails = .DropdownListEntries(i).Value
        Exit For
      End If
    Next
    With ActiveDocument.Tables(5)
      For i = 0 To 4
        .Rows(3).Cells(i + 1).Range.Text = Split(StrDetails, "|")(i)
      Next
      For i = 5 To 9
        .Rows(4).Cells(i - 4).Range.Text = Split(StrDetails, "|")(i)
      Next
      For i = 10 To 14
        .Rows(5).Cells(i - 9).Range.Text = Split(StrDetails, "|")(i)
      Next
    End With
  End If
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Content Control Dropdown Dependencies Move to next content control cksm4 Word VBA 13 07-02-2019 07:48 PM
Content Control Dropdown Dependencies Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
Content Control Dropdown Dependencies Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM
Content Control Dropdown Dependencies Hierarchical content control ntjson Word VBA 1 04-04-2013 12:07 AM
Content Control Dropdown Dependencies Content control titles jillapass Word VBA 3 05-29-2012 06:11 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:02 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