Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 08-12-2016, 04:28 AM
gmayor's Avatar
gmayor gmayor is offline table and code accidentally working only on odd rows Windows 10 table and code accidentally working only on odd rows Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 ofgmayor has much to be proud of
Default

Not only does your document have three tables, but each of those tables has two columns. The cell in the second column contains '0' formatted with 2 point Arial font?

It appears from your comments that you want to reduce the font size of the long paragraph in the first column until it fits on one line? That being the case the following macro will do the job.

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)
            Set oRng = oCell.Range
            oRng.End = oRng.Paragraphs(1).Range.End - 1
            Do While NumLines(oRng) > 1
                oRng.Font.Shrink
            Loop
        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
This will however result in some very tiny text in the example document.

If you want to mail merge into a table and create a new row for each record, then create a single row table. Put your merge fields in the cells of that row and set the merge type to 'Directory'. Merge to a new document.
__________________
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
table and code accidentally working only on odd rows I want to add multiple rows into my document but I can not figure out the code jlw15931 Mail Merge 1 02-24-2015 05:03 AM
table and code accidentally working only on odd rows Header Rows in Tables Not Working Andy Pilkington Word 2 10-10-2014 12:36 AM
table and code accidentally working only on odd rows Is it possible to copy non-contiguous rows of a Table and paste them as a separate Table in Word? Joey Cheung Word Tables 1 08-12-2014 05:15 PM
table and code accidentally working only on odd rows VBA Code to take data from a table in word document and place it in a summary table VBLearner Word VBA 1 03-09-2014 08:42 PM
table and code accidentally working only on odd rows Grouping table rows to prevent individual rows from breaking across pages dennist77 Word 1 10-29-2013 11:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:05 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft