PDA

View Full Version : Text Alignment: Justify to Left



magnel
08-22-2013, 04:40 AM
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)

John Wilson
08-24-2013, 05:30 AM
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

magnel
09-19-2013, 08:01 AM
Hi John, thank you so much for the code, works perfectly on the entire presentation.