Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-23-2017, 07:36 PM
gennatr12 gennatr12 is offline Edit table cells based on content control selection Windows 7 64bit Edit table cells based on content control selection Office 2016
Novice
Edit table cells based on content control selection
 
Join Date: Mar 2017
Posts: 4
gennatr12 is on a distinguished road
Default 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.
Attached Files
File Type: docm Equipment List.docm (27.0 KB, 13 views)
Reply With Quote
  #2  
Old 03-23-2017, 10:25 PM
macropod's Avatar
macropod macropod is offline Edit table cells based on content control selection Windows 7 64bit Edit table cells based on content control selection Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

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]
Reply With Quote
  #3  
Old 03-24-2017, 04:36 PM
gennatr12 gennatr12 is offline Edit table cells based on content control selection Windows 7 64bit Edit table cells based on content control selection Office 2016
Novice
Edit table cells based on content control selection
 
Join Date: Mar 2017
Posts: 4
gennatr12 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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.
I can't seem to find the original thread that I posted this to, so I'm unable to reference it. However on that thread in one of your earlier replies you posted the attached document. The one with the "Roundhouse Nurseries" drop-down list and it was able to output values to another content control (the one that uses your on-exit macro). In that example you had it outputting a phone number, a fax number, and an email address. I was trying to use that example you attached and instead of it outputting values separated by a line break (hitting the enter key) or whatever the technical term is, I was hoping to find a way for it to output those values into the cells of the table. On a side note, the content control in the first cell is a drop-down list whenever I open the document, so I'm not sure why you said that it wasn't even a drop-down. Do you not see the drop-down content control when you opened the previous attachment? Please let me know if I'm not being clear enough or if you need any other information as to what I am trying to accomplish. Thank you for your time.
Attached Files
File Type: docm Content Controls - Dropdown Dependent Text.docm (30.7 KB, 9 views)
Reply With Quote
  #4  
Old 03-24-2017, 10:44 PM
macropod's Avatar
macropod macropod is offline Edit table cells based on content control selection Windows 7 64bit Edit table cells based on content control selection Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 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]
Reply With Quote
  #5  
Old 03-25-2017, 08:37 AM
gennatr12 gennatr12 is offline Edit table cells based on content control selection Windows 7 64bit Edit table cells based on content control selection Office 2016
Novice
Edit table cells based on content control selection
 
Join Date: Mar 2017
Posts: 4
gennatr12 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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

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.
Attached Files
File Type: docm Equipment List - Copy.docm (30.2 KB, 14 views)
Reply With Quote
  #6  
Old 03-25-2017, 09:08 AM
gennatr12 gennatr12 is offline Edit table cells based on content control selection Windows 7 64bit Edit table cells based on content control selection Office 2016
Novice
Edit table cells based on content control selection
 
Join Date: Mar 2017
Posts: 4
gennatr12 is on a distinguished road
Default

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.
Reply With Quote
  #7  
Old 03-26-2017, 07:15 PM
Guessed's Avatar
Guessed Guessed is offline Edit table cells based on content control selection Windows 10 Edit table cells based on content control selection Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #8  
Old 03-26-2017, 08:51 PM
macropod's Avatar
macropod macropod is offline Edit table cells based on content control selection Windows 7 64bit Edit table cells based on content control selection Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit table cells based on content control selection 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 cells based on content control selection 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
Edit table cells based on content control selection Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM

Other Forums: Access Forums

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