View Single Post
 
Old 04-21-2023, 09:23 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
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

Maybe
Code:
Option Explicit

Sub TableFormat()
'Author:    Guessed (a/k/a Andrew Lockton)
'Date:      Unknown

Dim objTable As Table
Dim MyRange As Range
Dim oCell As Cell

Application.ScreenUpdating = False

    For Each objTable In Selection.Tables
      With objTable
         .Style = "Table Normal"        'clear any table style
         .RightPadding = 5              'measurement in points
         .LeftPadding = 5               'measurement in points
         .TopPadding = 0                'measurement in points
         .BottomPadding = 0             'measurement in points
         .Rows.SpaceBetweenColumns = CentimetersToPoints(0.2)
         .Rows.AllowBreakAcrossPages = False
         .Rows.Alignment = wdAlignRowCenter
         .Rows.HeightRule = wdRowHeightAuto
         .Borders.InsideLineStyle = wdLineStyleSingle
         .Borders.InsideLineWidth = wdLineWidth050pt
         .Borders.OutsideLineStyle = wdLineStyleSingle
         .Borders.OutsideLineWidth = wdLineWidth050pt
         .Borders.InsideColor = wdColorGray35
         .Borders.OutsideColor = wdColorGray35
         .Range.Style = ActiveDocument.Styles("Table Body")
         .Range.Font.Reset
         .Range.ParagraphFormat.Reset
         .Range.Cells.VerticalAlignment = wdAlignVerticalTop
         .AutoFitBehavior (wdAutoFitContent)
         .PreferredWidthType = wdPreferredWidthPercent
         .PreferredWidth = 100
        
         With .Rows(1)
           .Range.Style = ActiveDocument.Styles("Table Heading")
           .Range.Rows.HeadingFormat = True
           .Cells.VerticalAlignment = wdAlignVerticalCenter
           .Shading.Texture = wdTextureNone
           .Shading.ForegroundPatternColor = wdColorAutomatic
           .Shading.BackgroundPatternColor = 10448684
        End With      'end the first row settings
      For Each oCell In .Range.Cells
        Set MyRange = oCell.Range
        If InStr(1, MyRange.Text, "$") = 1 Then
            MyRange.ParagraphFormat.Alignment = wdAlignParagraphRight
        End If
      Next oCell
      End With        'end table settings
    
    Next objTable     'move to the next table selected
Application.ScreenRefresh
Application.ScreenUpdating = True
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