Link to home
Start Free TrialLog in
Avatar of Andreas Hermle
Andreas HermleFlag for Germany

asked on

run code on all of the tables omitting some of them

Dear Experts:

I would like to run below code (courtesy by Rgonzo1971, EE) not only on the selected table but on all of the tables in the active document with the exception of table 3, 5, 7 and 10.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas

Sub Format_Columns_Add_Decimal_tabs_selected_table()

Dim mytable As Table
Set d = ActiveDocument
Set mytable = Selection.Tables(1)
    With mytable
        For IdxRow = 2 To mytable.Rows.Count
            For IdxCol = 2 To 3
                Set c = mytable.Cell(IdxRow, IdxCol)
                c.Range.ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(1.7) _
                    , Alignment:=wdAlignTabDecimal, Leader:=wdTabLeaderSpaces
                 Next
        Next
       .PreferredWidth = 97.5
       .PreferredWidthType = wdPreferredWidthPercent
       .Columns(2).Width = CentimetersToPoints(3.1)
       .Columns(3).Width = CentimetersToPoints(3.1)
       .PreferredWidth = 97.5
       .PreferredWidthType = wdPreferredWidthPercent
    End With
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Andreas Hermle

ASKER

Great job, as always, thank you very much for your great and professional support.

Regards, Andreas