Consulting

Results 1 to 3 of 3

Thread: Text Alignment: Justify to Left

  1. #1

    Text Alignment: Justify to Left

    I am using PPT 2010, can we use vba to search justified text in the entire presentation and change it to left aligned text (irrespective of the text being in table or autoshape)

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    This is top of head code but should be pretty close and get you started

    Sub fixAlign()
    Dim oshp As Shape
    Dim osld As Slide
    Dim p As Long
    Dim iRow As Integer
    Dim iCol As Integer
    For Each osld In ActivePresentation.Slides
    For Each oshp In osld.Shapes
    Select Case oshp.HasTable
    Case Is = True
    For iRow = 1 To oshp.Table.Rows.Count
    For iCol = 1 To oshp.Table.Columns.Count
    For p = 1 To oshp.Table.Cell(iRow, iCol).Shape.TextFrame.TextRange.Paragraphs.Count
    If oshp.Table.Cell(iRow, iCol).Shape.TextFrame.TextRange.Paragraphs(p).ParagraphFormat.Alignment = ppAlignJustify Then _
    oshp.Table.Cell(iRow, iCol).Shape.TextFrame.TextRange.Paragraphs(p).ParagraphFormat.Alignment = ppAlignLeft
    Next p
    Next iCol
    Next iRow
    Case Else
    If oshp.HasTextFrame Then
    If oshp.TextFrame.HasText Then
    For p = 1 To oshp.TextFrame.TextRange.Paragraphs.Count
    If oshp.TextFrame.TextRange.Paragraphs(p).ParagraphFormat.Alignment = ppAlignJustify Then _
    oshp.TextFrame.TextRange.Paragraphs(p).ParagraphFormat.Alignment = ppAlignLeft
    Next p
    End If
    End If
    End Select
    Next oshp
    Next osld
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    Hi John, thank you so much for the code, works perfectly on the entire presentation.

Posting Permissions

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