Results 1 to 5 of 5

Thread: Align a line based on a value in the line

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,411
    Location
    Alignment in Word is a paragraph (not line) attribute. So unless each line is a paragraph, there isn't much you can do. If each line is a paragraph, and as the text with "XX" is already left aligned then all you need is:

    Sub ScratchMacro()
        ' A basic Word macro coded by Greg Maxey
        Dim oPar As Paragraph
        For Each oPar In ActiveDocument.Paragraphs
             If InStr(oPar.Range.Text, "YY") Then oPar.Alignment = wdAlignParagraphRight
        Next oPar
        lbl_Exit:
        Exit Sub
    End Sub
    Last edited by Aussiebear; 01-10-2025 at 01:30 PM.
    Greg

    Visit my website: http://gregmaxey.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •