#1
|
|||
|
|||
Legal Caption needs a way to dynamically create right-paren separator
I've included screenshots of my dilemma so I hopefully well keep this description short. I want to mail-merge legal documents that have a caption at the top which includes the parties (i.e. plaintiff, defendant). Here's an example of the styling. It's the right-paren in the center that's giving me trouble because the length of the parties information can vary. As a result, the number of right-parens required varies as well. I've been able to have some success using tables to get some of the formatting to flow properly but I'm searching for a way to dynamically determine the correct number of right-parens or some sort of auto-fill or default value for every new line within the table row. Please see the attachments for example of a good result vs. a bad result. Thanks! Last edited by gilly1; 03-08-2017 at 09:58 AM. Reason: subject line mispelling |
#2
|
||||
|
||||
What you could do, without the need for a separate column in your table, is use the mergefield \f switch to output the ')' for each populated line. That wouldn't help with lines that wrap, though, and there's no way for a mailmerge to generate the ')' in such cases. The alternative would be to use a macro to populate the column with ')' characters post-merge. The following macro will both execute the merge and update the output document post-merge.
Code:
Sub MailMergeToDoc() Dim Sctn As Section, sngHght As Single ActiveDocument.MailMerge.Execute For Each Sctn In ActiveDocument.Sections With Sctn.Range.Tables(1) sngHght = .Cell(1, 1).Range.Characters.Last.Previous.Information(wdVerticalPositionRelativeToPage) With .Cell(1, 2).Range .Text = "))))" Do While .Characters.Last.Previous.Information(wdVerticalPositionRelativeToPage) < sngHght .Characters.Last.InsertBefore ")" Loop End With End With Next End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
This is awesome! Thanks.
I ran into an error on the last iteration of the for loop where it could not find a table and would hang so I put in a conditional. I'm also testing gmayor's MMToDocs outbound to PDFCreator and saw that I could call this macro just before splitting the documents vs. doing the merging within this macro. Here's the adjusted code to use with MMToDocs. Code:
Sub MailMergeToDoc(aDoc As Document) Dim Sctn As Section, sngHght As Single 'Commented Out -- ActiveDocument.MailMerge.Execute For Each Sctn In aDoc.Sections If Sctn.Range.Tables.Count > 0 Then With Sctn.Range.Tables(1) .Cell(1, 2).Range.Characters.Last.Previous.Select sngHght = .Cell(1, 1).Range.Characters.Last.Previous.Information(wdVerticalPositionRelativeToPage) With .Cell(1, 2).Range .Text = "))))" Do While .Characters.Last.Previous.Information(wdVerticalPositionRelativeToPage) < sngHght .Characters.Last.InsertBefore ")" Loop End With End With End If Next End Sub |
Tags |
legal pleadings |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Automatically Organize data in a sheet differently (in order to create a dynamically updated graph) | carlos_cs | Excel | 3 | 05-04-2016 08:44 AM |
Auto add a right paren at end of line | dlowrey | Word | 2 | 10-07-2014 07:10 AM |
Combining two pieces of VBA to create caption field above table | lsmcal1984 | Word VBA | 1 | 08-16-2013 04:12 AM |
Dynamically create documents | MrRikkie | Word VBA | 1 | 10-12-2012 09:15 AM |
Add automatic separator in caption "Figure 1: __" | poobear | Word | 1 | 05-12-2011 04:05 PM |