View Single Post
 
Old 01-20-2021, 10:42 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Not exactly sure what you are trying to do. First, it seems your code could be written:

Code:
Sub Create_Dot_Leader_1Tbl_Col_1_SpacedOut()
Dim oTbl As Table
Dim oRow As Row
Dim oCell As Cell
Dim oRng As Range
  Application.ScreenUpdating = False
  Set oTbl = Selection.Tables(1)
  oTbl.Columns(1).Select
  With Selection.ParagraphFormat
    .TextboxTightWrap = wdTightNone
    .CollapsedByDefault = False
    .TabStops.ClearAll
    .TabStops.Add Position:=InchesToPoints(5.25), _
         Alignment:=wdAlignTabRight, Leader:=wdTabLeaderDots
  End With
  For Each oRow In oTbl.Rows
    Set oRng = oRow.Cells(1).Range
    With oRng
      .End = .End - 1
      .Collapse wdCollapseEnd
      .InsertAfter vbTab
      With .Font
        .Bold = False
        .Color = wdColorAutomatic
        .Spacing = 2
      End With
    End With
  Next oRow
  Application.ScreenUpdating = True
lbl_Exit:
  Exit Sub
End Sub

To process all tables then change to this:

Code:
Sub Create_Dot_Leader_1Tbl_Col_1_SpacedOut()
Dim oTbl As Table
Dim oRow As Row
Dim oCell As Cell
Dim oRng As Range
  Application.ScreenUpdating = False
  For Each oTbl in ActiveDocument.Tables 'Set oTbl = Selection.Tables(1)
  oTbl.Columns(1).Select
  With Selection.ParagraphFormat
    .TextboxTightWrap = wdTightNone
    .CollapsedByDefault = False
    .TabStops.ClearAll
    .TabStops.Add Position:=InchesToPoints(5.25), _
         Alignment:=wdAlignTabRight, Leader:=wdTabLeaderDots
  End With
  For Each oRow In oTbl.Rows
    Set oRng = oRow.Cells(1).Range
    With oRng
      .End = .End - 1
      .Collapse wdCollapseEnd
      .InsertAfter vbTab
      With .Font
        .Bold = False
        .Color = wdColorAutomatic
        .Spacing = 2
      End With
    End With
  Next oRow
  Next oTbl
  Application.ScreenUpdating = True
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote