#1
|
|||
|
|||
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) |
#2
|
||||
|
||||
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] |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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".
|
#5
|
||||
|
||||
Quote:
Quote:
ActiveDocument.ContentControls(2).Range.Text = StrDetails with: ActiveDocument.SelectContentControlsByTitle("Clien tDetails").Item(1).Range.Text = StrDetails
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
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.
|
#7
|
||||
|
||||
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] |
#8
|
|||
|
|||
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 |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
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 |