Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-07-2017, 12:58 PM
gilly1 gilly1 is offline Legal Caption needs a way to dynamically create right-paren separator Windows 7 64bit Legal Caption needs a way to dynamically create right-paren separator Office 2007
Novice
Legal Caption needs a way to dynamically create right-paren separator
 
Join Date: Mar 2017
Posts: 2
gilly1 is on a distinguished road
Default 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!
Attached Images
File Type: png good_legal_caption.png (9.7 KB, 18 views)
File Type: png bad_legal_caption.png (15.4 KB, 17 views)

Last edited by gilly1; 03-08-2017 at 09:58 AM. Reason: subject line mispelling
Reply With Quote
  #2  
Old 03-07-2017, 03:06 PM
macropod's Avatar
macropod macropod is offline Legal Caption needs a way to dynamically create right-paren separator Windows 7 64bit Legal Caption needs a way to dynamically create right-paren separator Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

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
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 03-08-2017, 08:39 AM
gilly1 gilly1 is offline Legal Caption needs a way to dynamically create right-paren separator Windows 7 64bit Legal Caption needs a way to dynamically create right-paren separator Office 2007
Novice
Legal Caption needs a way to dynamically create right-paren separator
 
Join Date: Mar 2017
Posts: 2
gilly1 is on a distinguished road
Default

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
Thanks again!
Reply With Quote
Reply

Tags
legal pleadings

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Legal Caption needs a way to dynamically create right-paren separator 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
Legal Caption needs a way to dynamically create right-paren separator 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

Other Forums: Access Forums

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