#1
|
|||
|
|||
Edit table cells based on content control selection
In the attached document. Is it possible to make the output values go to 5 separate cells in a table? Such that, the description would be under the description column, the manufacturer would be under the manufacturer column, and so on? Any help would be greatly appreciated.
|
#2
|
||||
|
||||
It's by no means apparent from your attachment what the 'output values' are of where they'd come from. Your content control isn't even a dropdown - which is what the thread you posted in concerns (I've moved this discussion to a thread of its own). If you're contemplating having the values typed into a text content control, I can't see how that would be as efficient as typing the details directly into the cells concerned - apart from which, you'd need to have one such content control on every row or some fancy coding to have Word find the next available row.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Quote:
|
#4
|
||||
|
||||
The original thread was: https://www.msofficeforums.com/word-...own-lists.html
Regarding my previous post, your 'Client' dropdown has only one meaningful item, so there's no real point in it being a dropdown, and your 'client details' content control isn't a dropdown either, so you can't choose from any of its 'Description, 'Manufacturer', 'Model', 'Serial No.', or Cal. Due' entries. Hence my comments re a lack of clarity. But, yes, it is possible to modify the macro to populate a series of table cells. For example: Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean) Dim i As Long, j As Long, StrDetails As String With CCtrl If .Title = "Client" Then For i = 1 To .DropdownListEntries.Count If .DropdownListEntries(i).Text = .Range.Text Then StrDetails = .DropdownListEntries(i).Value For j = 0 To UBound(Split(StrDetails, "|")) .Range.Rows(1).Cells(j + 2).Range.Text = Split(StrDetails, "|")(j) Next Exit For End If Next End If End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Quote:
I just wanted to thank you for helping me out. I was trying to figure out a way so that when you select an option from the drop-down list content control(the one under the 'Asset No.' column) it would fill out the remaining adjacent table cells. So in the attached document you can select an asset number from the drop-down list and it will populate the table cells with the corresponding data(description, manufacturer, model, serial, and calibration due). When it's all said and done the drop-down list will have a lot more options to choose from, but for now this was just an example for me to test everything out. I may have more questions later on, but for now this is exactly what I needed. Again, thank you so much for your help. |
#6
|
|||
|
|||
And by later on, I mean I have a question now. So in your code you have this line:
If .Title = "Client" Then How would I go about editing the code to allow more than one title name. For example I wanted to have one drop-down list with the title Client and a second(separate) drop-down list with the title Client1. Thank you for your time and any help is greatly appreciated. |
#7
|
||||
|
||||
You can handle multiple CCs by using a Select Case or ElseIf. Personally, I find the Select Case to be a bit more flexible so an example would be
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean) Dim i As Long, j As Long, StrDetails As String With CCtrl Select Case .Title Case "Client" 'do something Case "Client1", "Client2", "Client3" 'do something else End Select End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#8
|
||||
|
||||
True, but with the code I posted, if all the content controls in column 1 of the table are performing the same function, just on different rows, one could just as easily title all of the 'Client'. Regardless of which approach is used, one still needs to get the RowIndex. Indeed, if these are the only content controls in the document, one doesn't even need to test the title!
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
Edit table in content control | denise do rocio maciel | Word VBA | 2 | 01-03-2016 11:59 PM |
How-to: Add a quickpart, field or Building Block Gallery Content Control based on a UserForm | HighSierra | Word VBA | 0 | 05-06-2015 08:20 PM |
Combo Box Content Control Calculate on selection help | ciresuark | Word | 0 | 03-06-2015 01:49 PM |
Deleting a table from a content control -- preserving the content control | BrainSlugs83 | Word Tables | 8 | 11-14-2013 03:06 AM |