Thread: [Solved] Need a macro adjustment
View Single Post
 
Old 12-08-2021, 09:30 PM
Bikram Bikram is offline Windows 10 Office 2007
Advanced Beginner
 
Join Date: Jul 2021
Location: Nepal
Posts: 90
Bikram is on a distinguished road
Default

Dear ULOdesk, You can use the following code to target tables that are wrapped around text.
Code:
Sub Formattingtables()
    Dim i As Integer
    Dim ii As Integer
    Dim doc As Document

        Set doc = ActiveDocument
            ii = doc.Tables.Count
        For i = 1 To ii
            If doc.Tables(i).Rows.WrapAroundText = True Then
                'Ignore the wrapped Tables
            Else
                'Apply formatting to Non - wrapped Tables
                With doc.Tables(i)
                    .AutoFitBehavior wdAutoFitFixed
                    .PreferredWidthType = wdPreferredWidthPoints
                    .PreferredWidth = InchesToPoints(7.2)
                    .Rows.Alignment = wdAlignRowLeft
                    .Rows.LeftIndent = InchesToPoints(0.3)
                End With
            End If
        Next
End Sub
Reply With Quote