Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #31  
Old 10-26-2015, 01:46 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,664
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

You need to be clear about what your requirements are.



First you asked about how to have the output appear somewhere other than where the dropdown was located, which I answered.

Then you changed the question after the event to say you wanted to include the dropdown value included in the output at that other location also, which I have also answered.

Now it seems you're saying you want to have the full details appear in multiple locations. Don't keep moving the goal posts. When you've decided what it is you want, post back with the details of what that is.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #32  
Old 10-26-2015, 02:35 PM
maverick561145 maverick561145 is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Oct 2015
Posts: 8
maverick561145 is on a distinguished road
Default

OK. I have a document that I have a dropdown box for my customer on page one when I choose my customer the address pops up. There is another location on page 3 that I need the same customer name to pop up there. Like I said earlier I can get the correct address to appear on page 3. just not the name of the customer. Thank you .
Reply With Quote
  #33  
Old 10-26-2015, 03:23 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,664
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Try:
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 = Replace(.DropdownListEntries(i).Value, "|", Chr(11))
        Exit For
      End If
    Next
    With ActiveDocument
      .SelectContentControlsByTitle("ClientAddress").Item(1).Range.Text = StrDetails
      If StrDetails <> " " Then StrDetails = _
      .SelectContentControlsByTitle("Client").Item(1).Range.Text & Chr(11) & StrDetails 
      .SelectContentControlsByTitle("ClientDetails").Item(1).Range.Text = StrDetails
    End With
  End If
End With
End Sub
Note that the above code assumes:
1. The dropdown (and any other ordinary control requiring only the client name) is titled 'Client';
2. Every content control requiring just the client address is titled 'ClientAddress'; and
3. Every content control requiring the client name & address is titled 'ClientDetails'.
Where you have multiple copies of any of these content controls to update, just refer to each by its index #, remembering to update all those with 'ClientAddress' before updating any with 'ClientDetails'.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #34  
Old 10-26-2015, 04:49 PM
maverick561145 maverick561145 is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Oct 2015
Posts: 8
maverick561145 is on a distinguished road
Default

Thank you for all of your help....That is just what I needed.
Reply With Quote
  #35  
Old 11-30-2015, 12:04 PM
maverick561145 maverick561145 is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Oct 2015
Posts: 8
maverick561145 is on a distinguished road
Default

Paul,
Everything that you have helped we with is working fantastic, the question I have is. I have the drop down lists of my customers in 9 different places on my document, Is there a way to add a new customer to all of the drop down lists at the same time or do I need to add the customer to each drop down list in in the document individually.

Last edited by maverick561145; 11-30-2015 at 12:05 PM. Reason: missed a word
Reply With Quote
  #36  
Old 11-30-2015, 02:46 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,664
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Quote:
Originally Posted by maverick561145 View Post
I have the drop down lists of my customers in 9 different places on my document, Is there a way to add a new customer to all of the drop down lists at the same time or do I need to add the customer to each drop down list in in the document individually.
Please be clear about your requirements - do you have nine dropdowns, each of which someone can choose a customer from, or do you have one dropdown that outputs the selection to eight different locations? These are entirely different things.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #37  
Old 11-30-2015, 02:52 PM
maverick561145 maverick561145 is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Oct 2015
Posts: 8
maverick561145 is on a distinguished road
Default Response

I have nine seperate dropdown boxs that you need to choose a customer from.
Reply With Quote
  #38  
Old 11-30-2015, 07:09 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,664
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

In that case, you need to add all the choices to all 9 dropdowns. You could, of course, just create one dropdown with all the choices, then copy/paste that dropdown to each of the other 8 locations.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #39  
Old 02-01-2016, 09:40 AM
Tim Tayler Tim Tayler is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Jan 2016
Posts: 7
Tim Tayler is on a distinguished road
Default

Thanks a lot, Macropod!
I've got another question, though. Unfortunately I'm absolutely new on macros...

I copied the macro from the template you posted in the beginning. Then I copied the box twice, because I need two drop-down boxes next to each other in my template (that didn't work, the second box triggered a change under the first box). I want the two drop-down boxes to work individually. The output shall appear right under the box (just like in the template you posted). How do I have to change the macro/ What shall I do?

Hope my question is sufficiently precise...

I'd be super grateful for any help!

Regards,
Tim
Reply With Quote
  #40  
Old 02-01-2016, 02:50 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,664
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

If you want independent dropdowns, simply don't give them both the same title. The demonstration one is titled 'Client'. If you want the second one to trigger its own set of outputs, the existing code would need to be supplemented with its own processes within the ContentControlOnExit macro.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #41  
Old 02-02-2016, 02:40 AM
Tim Tayler Tim Tayler is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Jan 2016
Posts: 7
Tim Tayler is on a distinguished road
Default

Thanks again, macropod!

I just tried adding a changed process to the code. It didn't work out, though. My knowledge about macros isn't sufficient I guess.
Could you, or anybody else in here, post the code that would make my template work?
As usual I'd be very grateful for any help

Thank you, have a good one.

Regards
Tim
Reply With Quote
  #42  
Old 02-02-2016, 01:21 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,664
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Quote:
Originally Posted by Tim Tayler View Post
Could you, or anybody else in here, post the code that would make my template work?
Not without knowing what your template contains and how you intend it to function. Can you attach it to a post (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #43  
Old 02-04-2016, 01:59 AM
Tim Tayler Tim Tayler is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Jan 2016
Posts: 7
Tim Tayler is on a distinguished road
Default

Cheers!
On the second page you'll find a box containing two cells. The left cell already works as it's supposed to: I can select an entry from a drop-down list and that triggers an entry below the drop-down. That's exactly what you posted (I used your macro). The right cell shall work exactly the same way, but independently from the left cell. I want to be able to select entries in each cell (drop-down) which then triggers a line right under each drop-down.
Please let me know, if I explained insufficiently.

Thanks a lot!!!

Regards
Tim
Attached Files
File Type: docm Quotation Template_Tim Tayler.docm (49.4 KB, 36 views)
Reply With Quote
  #44  
Old 02-04-2016, 03:31 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,664
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Given that the second cell doesn't even have any content controls, I can only guess at what you want.

Suppose the dropdown content control in the 1st cell is titled 'ClientA' and the dropdown content control in the 2nd cell is titled 'ClientB'. Suppose also the text content control in the 1st cell is titled 'ClientDetailsA' and the text content control in the 2nd cell is titled 'ClientDetailsB'. In that case, you could use a macro like:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim i As Long, StrDetails As String
With ContentControl
  If .Title = "ClientA" Then
    For i = 1 To .DropdownListEntries.Count
      If .DropdownListEntries(i).Text = .Range.Text Then
        StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11))
        Exit For
      End If
    Next
    With ActiveDocument.SelectContentControlsByTitle("ClientDetailsA")(1)
      .LockContents = False
      .Range.Text = StrDetails
      .LockContents = True
    End With
  ElseIf .Title = "ClientB" Then
    For i = 1 To .DropdownListEntries.Count
      If .DropdownListEntries(i).Text = .Range.Text Then
        StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11))
        Exit For
      End If
    Next
    With ActiveDocument.SelectContentControlsByTitle("ClientDetailsB")(1)
      .LockContents = False
      .Range.Text = StrDetails
      .LockContents = True
    End With
  End If
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #45  
Old 02-04-2016, 06:01 AM
Tim Tayler Tim Tayler is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Jan 2016
Posts: 7
Tim Tayler is on a distinguished road
Default

That works perfectly! Thank you so much, macropod!!!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Multiple Entries dudeabides Office 1 07-04-2011 02:49 AM
Multiple task lists and multiple calendars kballing Outlook 0 01-18-2011 10:23 AM
Creating Multiple Contact Lists meltee78 Outlook 1 01-03-2011 09:45 PM
multiple calendar entries across a group halfhearted Outlook 0 10-11-2009 12:13 PM
Word Forms : Dropdown lists wferaera45 Word 0 04-06-2006 03:02 AM


All times are GMT -7. The time now is 10:44 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft