Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-22-2016, 05:21 AM
gmayor's Avatar
gmayor gmayor is offline Word table auto text alignment vs cell height Windows 10 Word table auto text alignment vs cell height Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
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

In the absence of a sample table, your requirement doesn't appear to make sense.



What the code appears to suggest is that if the row height is 6 point (which seems improbable) then the row is formatted as with your first set of codes, whereas if it is greater than 6 point (which seems to be the more likely scenario) it is formatted with the second set.

The only difference between the two is that the second set has the text aligned to center, whereas in the first it is left aligned.

Code:
Sub FormatTables()
Dim oTable As Table
Dim oRow As Row
    For Each oTable In ActiveDocument.Tables
        For Each oRow In oTable.Rows
            With oRow.Range
                .Font.Name = "Arial"
                .Font.ColorIndex = wdBlack
                .Font.Size = 11
                .Cells.VerticalAlignment = wdCellAlignVerticalTop
                .HighlightColorIndex = wdYellow
            End With
            If oRow.Height <= 6 Then
                oRow.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
            Else
                oRow.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
            End If
        Next oRow
    Next oTable
lbl_Exit:
    Set oRow = Nothing
    Set oTable = Nothing
    Exit Sub
End Sub
__________________
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
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pasting text from Excel cell into word without creating a table, and keeping the in-cell formatting hanvyj Excel Programming 0 08-28-2015 01:15 AM
Word table auto text alignment vs cell height Row auto height markand_bhatt2008 Excel 1 04-29-2013 07:46 AM
Word table auto text alignment vs cell height table cell alignment issue gib65 Word 1 06-02-2012 03:03 PM
Word table auto text alignment vs cell height Table Text Alignment? Jazz43 Word Tables 2 08-19-2010 08:07 AM
Auto-populate an MS Word table cell with text from a diff cell? dreamrthts Word Tables 0 03-20-2009 01:49 PM

Other Forums: Access Forums

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