View Single Post
 
Old 03-08-2017, 08:39 AM
gilly1 gilly1 is offline Windows 7 64bit Office 2007
Novice
 
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