0

Is there a way to align the text from right to left (it's Arabic) on all slides in a PowerPoint Presentation with a macro ? (I'm using O365).

In a Microsoft example I found this :

Application.ActivePresentation.Slides(1).Shapes(2) _
    .TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignLeft

But i think that this example aligns the paragraphs of form 2 on slide 1 of the active presentation to the left.

So i don't know how to do it with all the shapes/slides types.

1 Answer 1

1

The professional coders may improve it, but I think this one should help you. You just have to select all slides before you click it, if you want the entire presentation to be done in one move. I think it is better than any entire-presentation-solution, because it gives you the opportunity to choose.

Option Explicit

Sub AlignAllTextLeft()
 
Dim osld As Slide
Dim oshp As Shape
Dim notesshp As Shape
Dim i As Long
Dim j As Long
Dim x As Long

    On Error GoTo ErMsg

    If MsgBox("You are going to change the text alignment of all text on all selected slides to left" & vbCrLf & "Continue?", vbYesNo) <> vbYes Then Exit Sub
 
For Each osld In ActiveWindow.Selection.SlideRange
 For Each oshp In osld.Shapes
 If oshp.HasTextFrame Then
 oshp.TextFrame2.TextRange.ParagraphFormat.Alignment = msoAlignLeft
 End If
 If oshp.HasTable Then
             For i = 1 To oshp.Table.Rows.Count
                For j = 1 To oshp.Table.Columns.Count
 oshp.Table.Rows.Item(i).Cells(j).Shape.TextFrame2.TextRange.ParagraphFormat.Alignment = msoAlignLeft
                 Next j
            Next i
 End If
 Next oshp

 For Each notesshp In osld.NotesPage.Shapes
 If notesshp.HasTextFrame Then
 notesshp.TextFrame2.TextRange.ParagraphFormat.Alignment = msoAlignLeft
 End If
 Next notesshp
 Next osld
 
For Each osld In ActiveWindow.Selection.SlideRange
    For Each oshp In osld.Shapes
    
        With oshp
            Select Case .Type
                Case Is = msoGroup
                For x = 1 To .GroupItems.Count
                    If .GroupItems(x).HasTextFrame Then
                         oshp.TextFrame2.TextRange.ParagraphFormat.Alignment = msoAlignLeft
                    End If
                Next x
            End Select
        End With
    Next oshp
    Next

Exit Sub

ErMsg:
    MsgBox "Please do not place the cursor between two slides"

End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.