View Single Post
 
Old 10-28-2019, 05:23 AM
abc3132 abc3132 is offline Windows 7 64bit Office 2007
Novice
 
Join Date: Feb 2015
Posts: 24
abc3132 is on a distinguished road
Default Thanks Gmayor

Quote:
Originally Posted by gmayor View Post
Automatically would be a stretch, but you can use a macro to create a tab at the right margin and add a tab with a dashed leader to fill the space. Put the cursor in the 'line' in question and run the macro
Code:
Sub TabToEndOfLine()

Dim lngWidth As Long, lngLM As Long, lngRM As Long
Dim oRng As Range
    
    With Selection.Sections(1).PageSetup
        lngLM = .LeftMargin
        lngRM = .RightMargin
        lngWidth = .PageWidth
    End With

    Set oRng = Selection.Paragraphs(1).Range
    oRng.End = oRng.End - 1
    With oRng.ParagraphFormat.TabStops
        .ClearAll
        .Add Position:=lngWidth - lngLM - lngRM, _
             Alignment:=wdAlignTabRight, _
             Leader:=2
    End With
    oRng.Collapse 0
    oRng.Text = Chr(32) & vbTab
    oRng.End = oRng.Paragraphs(1).Range.End + 1
    oRng.Collapse 0

    oRng.Select
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
Thanks Gmayor. Brilliant! it works very well
Reply With Quote