Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2021, 09:28 PM
jsarchibald jsarchibald is offline Selecting Drop-Down Auto-Populates formatted paragraphs of text Windows 10 Selecting Drop-Down Auto-Populates formatted paragraphs of text Office 2019
Novice
Selecting Drop-Down Auto-Populates formatted paragraphs of text
 
Join Date: Jan 2021
Posts: 1
jsarchibald is on a distinguished road
Default Selecting Drop-Down Auto-Populates formatted paragraphs of text

Happy New Year!

I work in a company that generates many contracts per year, but working across different states we have to reference State-specific Legislation in each agreement (taking up over 20 pages, making the agreements seem more daunting than they actually are). At the front of the document, you need to select the Jurisdiction that the contract will be in, and I am wanting to use this drop-down to govern the formatted text so that only the relevant Legislation for that state is shown.

This is well beyond my level of knowledge. The solution would need to be transportable with the document (ie. Not saved only to my Normal.dot file) as many people will be involved in drafting documents, and for the text to be properly formatted and look professional. Is this achievable or do I need to call in a specialist? I have been tinkering and researching for 12 months to no avail.

I have seen several solutions, but they do not provide formatted text, or they require a change to your Normal.dot file, or don’t play nice with newer file formats.

I am also keen to explore other functionality, such as:

- Selecting a check box for one item which changes a comment from Not Applicable to Insert


- Selecting a company auto-populates their company number, and so on
- Conditional Formatting would be useful to prompt someone to make a selection, which would be highlighted blue to prompt them for a selection, with the highlighting removed once a selection is made

I hope this makes sense, and I think I could cut the complexity in half by these small changes (not to mention the time saved drafting each individual document). I welcome any input you may have, and thanks for adding me to your forum!
Reply With Quote
  #2  
Old 01-05-2021, 09:38 PM
gmayor's Avatar
gmayor gmayor is offline Selecting Drop-Down Auto-Populates formatted paragraphs of text Windows 10 Selecting Drop-Down Auto-Populates formatted paragraphs of text Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The best way to do this would be to create a template that you can supply to colleagues.
The template would contain a userform in which you select the various options required for the document Create a userform .
It is then a relatively simple matter to write the variable text items to the document using rich text content controls to hold the formatted data which could be held in autotext entries stored in the template, using code similar to
Code:
Sub AutoTextToCC(strCCName As String, oTemplate As Template, strAutotext As String)
'Graham Mayor - https://www.gmayor.com - Last updated - 10 Apr 2019
'strCCName is the ContentControl title
'oTemplate is the template with the autotext entry
'strAutotext is the name of the autotext entry
Dim oCC As ContentControl
    On Error GoTo lbl_Exit
    For Each oCC In ActiveDocument.ContentControls
        If oCC.Title = strCCName Then
            oCC.LockContentControl = True
            oTemplate.AutoTextEntries(strAutotext).Insert Where:=oCC.Range, RichText:=True
            Exit For
        End If
    Next oCC
lbl_Exit:
    Exit Sub
End Sub
If you need a specialist, contact me via my web site.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 01-06-2021, 03:47 AM
gmaxey gmaxey is offline Selecting Drop-Down Auto-Populates formatted paragraphs of text Windows 10 Selecting Drop-Down Auto-Populates formatted paragraphs of text Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Graham,


Why the loop?

Code:
Sub AutoTextToCC(strCCName As String, oTemplate As Template, strAutotext As String)
'Graham Mayor - https://www.gmayor.com - Last updated - 10 Apr 2019
'strCCName is the ContentControl title
'oTemplate is the template with the autotext entry
'strAutotext is the name of the autotext entry
Dim oCC As ContentControl
  On Error GoTo lbl_Exit
  Set oCC = ActiveDocument.SelectContentControlsByTitle(strCCName).Item(1)
  oCC.LockContentControl = True
  oTemplate.AutoTextEntries(strAutotext).Insert Where:=oCC.Range, RichText:=True
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled spinn2046@gmail.com Word VBA 17 09-15-2020 04:13 PM
Selecting Drop-Down Auto-Populates formatted paragraphs of text Auto Populate Text On Dependent Drop Down Exit GregStewartPTC Word VBA 2 02-27-2017 05:37 AM
Auto Text Drop Down List AJohn403 Word 3 05-01-2015 05:00 AM
Selecting Drop-Down Auto-Populates formatted paragraphs of text Text auto formatted as date format Aikeedoh Excel 5 09-06-2013 02:38 AM
Selecting Drop-Down Auto-Populates formatted paragraphs of text Date auto-populates based on checkbox mcarter9000 Word VBA 5 12-23-2010 12:39 PM

Other Forums: Access Forums

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