![]() |
#12
|
||||
|
||||
![]()
The reason that the merge produces a separate table for each record is that the merge document contains a section break, which forces the creation of a new table. Remove the section break from the merge document and the merge is to separate rows.
Adding the paragraph collection, as I suggested processes all the first column paragraphs, whether there is one table or many. Code:
Option Explicit Sub ShrinkParagraphText() Dim oTable As Table Dim oRow As Row Dim oCell As Cell Dim oRng As Range Dim oPara As Paragraph For Each oTable In ActiveDocument.Tables For Each oRow In oTable.Rows Set oCell = oRow.Cells(1) For Each oPara In oCell.Range.Paragraphs Set oRng = oPara.Range oRng.End = oRng.End - 1 Do While NumLines(oRng) > 1 oRng.Font.Shrink Loop Next oPara Next oRow Next oTable lbl_Exit: Set oTable = Nothing Set oRow = Nothing Set oCell = Nothing Set oRng = Nothing Set oPara = Nothing Exit Sub End Sub Function NumLines(rng As Range) As Long Const wdStatisticLines As Long = 1 NumLines = rng.ComputeStatistics(wdStatisticLines) lbl_Exit: Exit Function End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
jlw15931 | Mail Merge | 1 | 02-24-2015 05:03 AM |
![]() |
Andy Pilkington | Word | 2 | 10-10-2014 12:36 AM |
![]() |
Joey Cheung | Word Tables | 1 | 08-12-2014 05:15 PM |
![]() |
VBLearner | Word VBA | 1 | 03-09-2014 08:42 PM |
![]() |
dennist77 | Word | 1 | 10-29-2013 11:39 PM |