View Single Post
 
Old 10-29-2019, 07:40 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

OK, this code adds the line to every paragraph including table cells (except for the last para in the last cell of a table)
Code:
Sub TabToEndOfLine()
  Dim lngWidth As Long, lngLM As Long, lngRM As Long
  Dim oRng As Range, lngColWidth As Long
  Dim oPara As Paragraph
  On Error Resume Next
  For Each oPara In ActiveDocument.Paragraphs
    Set oRng = oPara.Range
    If oPara.Range.Information(wdWithInTable) = False Then
      lngColWidth = oRng.Sections(1).PageSetup.TextColumns.Width
    Else ' in a table
      lngColWidth = oRng.Cells(1).Width
    End If
    With oRng.ParagraphFormat.TabStops
      .ClearAll
      .Add Position:=lngColWidth, Alignment:=wdAlignTabRight, Leader:=2
    End With
    oRng.End = oRng.End - 1
    oRng.InsertAfter Chr(32) & vbTab
    DoEvents
  Next oPara
lbl_Exit:
  Set oRng = Nothing
  Set oPara = Nothing
  Exit Sub
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote