Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-07-2016, 03:17 AM
JakeLRL JakeLRL is offline Dropdown dependent text Windows 7 32bit Dropdown dependent text Office 2013
Novice
Dropdown dependent text
 
Join Date: Mar 2016
Posts: 13
JakeLRL is on a distinguished road
Default Dropdown dependent text

My question is similar to a previous thread - https://www.msofficeforums.com/word-...html#post46903 however, it is a larger block of text after the initial selection, and it doesn't fit in the value section so it cuts off some of the text.

Is there another solution which will work?

(also cant see the macros on the doc provided in the aforementioned thread)
Reply With Quote
  #2  
Old 04-07-2016, 03:46 AM
macropod's Avatar
macropod macropod is offline Dropdown dependent text Windows 7 64bit Dropdown dependent text 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

Instead of adding text to the content control value, you could use code like:
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
        Select Case i
          Case 1
            StrDetails = "On the Insert tab, the galleries include items that are designed to coordinate with " & _
              "the overall look of your document. You can use these galleries to insert tables, headers, " & _
              "footers, lists, cover pages, and other document building blocks."
          Case 2
            StrDetails = "When you create pictures, charts, or diagrams, they also coordinate with your current " & _
              "document look. You can easily change the formatting of selected text in the document text by " & _
              "choosing a look for the selected text from the Quick Styles gallery on the Home tab." & Chr(11) & "You " & _
              "can also format text directly by using the other controls on the Home tab. Most controls offer a " & _
              "choice of using the look from the current theme or using a format that you specify directly."
          Case 3
            StrDetails = "To change the overall look of your document, choose new Theme elements on the Page Layout " & _
              "tab. To change the looks available in the Quick Style gallery, use the Change Current Quick Style Set " & _
              "command. Both the Themes gallery and the Quick Styles gallery provide reset commands so that you can " & _
              "always restore the look of your document to the original contained in your current template."
          Case Else: StrDetails = " "
        End Select
      End If
    Next
    ActiveDocument.ContentControls(2).Range.Text = StrDetails
  End If
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-07-2016, 03:50 AM
JakeLRL JakeLRL is offline Dropdown dependent text Windows 7 32bit Dropdown dependent text Office 2013
Novice
Dropdown dependent text
 
Join Date: Mar 2016
Posts: 13
JakeLRL is on a distinguished road
Default

Do I just copy and paste this into the VBA coding area and change the relevent things?

Last edited by JakeLRL; 04-07-2016 at 03:50 AM. Reason: typo
Reply With Quote
  #4  
Old 04-07-2016, 04:04 AM
JakeLRL JakeLRL is offline Dropdown dependent text Windows 7 32bit Dropdown dependent text Office 2013
Novice
Dropdown dependent text
 
Join Date: Mar 2016
Posts: 13
JakeLRL is on a distinguished road
Default

I started editing it, how do I get the text to go into a certain content control section like the start of the dropdown is linked with the word "Client", in this casse, I want it to go into a text content control area named "ClientDetails".
Reply With Quote
  #5  
Old 04-07-2016, 04:13 AM
macropod's Avatar
macropod macropod is offline Dropdown dependent text Windows 7 64bit Dropdown dependent text 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

Quote:
Originally Posted by JakeLRL View Post
Do I just copy and paste this into the VBA coding area and change the relevent things?
Yes.
Quote:
Originally Posted by JakeLRL View Post
I started editing it, how do I get the text to go into a certain content control section like the start of the dropdown is linked with the word "Client", in this casse, I want it to go into a text content control area named "ClientDetails".
In that case, you could replace:
ActiveDocument.ContentControls(2).Range.Text = StrDetails
with:
ActiveDocument.SelectContentControlsByTitle("Clien tDetails").Item(1).Range.Text = StrDetails
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 04-07-2016, 06:59 AM
JakeLRL JakeLRL is offline Dropdown dependent text Windows 7 32bit Dropdown dependent text Office 2013
Novice
Dropdown dependent text
 
Join Date: Mar 2016
Posts: 13
JakeLRL is on a distinguished road
Default

Is there a way to make this function usable in 2 different situations or if not are you able to have 2 separate functions with different names which do the same thing in the same document and if so, how do you do it, thanks in advance.
Reply With Quote
  #7  
Old 04-07-2016, 08:19 AM
macropod's Avatar
macropod macropod is offline Dropdown dependent text Windows 7 64bit Dropdown dependent text 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

It's not clear what you mean by '2 different situations'. If you want to be able to use two sets of content controls, simply give the second set of controls a different pair of titles and add another 'If .Title = ... End If' block for those.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 04-07-2016, 08:26 AM
JakeLRL JakeLRL is offline Dropdown dependent text Windows 7 32bit Dropdown dependent text Office 2013
Novice
Dropdown dependent text
 
Join Date: Mar 2016
Posts: 13
JakeLRL is on a distinguished road
Default

Thanks, that has solved my issue, can you set this thread as solved please.

Last edited by JakeLRL; 04-07-2016 at 08:26 AM. Reason: typo
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown dependent text Link text field to dropdown list borus Word 3 08-16-2023 05:36 AM
make text form field active dependent on dropdown Glenn0004 Word VBA 1 06-23-2015 06:13 PM
Dropdown dependent text Auto text after selection from Dropdown menu trainsy Word 2 06-04-2014 04:43 AM
VBA: How to place dropdown list next to text YigalB Word VBA 0 08-11-2013 01:48 PM
Macro to populate a text form field based on dropdown selection koloa Word 0 10-20-2011 11:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:46 PM.


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