2017-06-02 3 views
0

J'ai beaucoup de diapositives, chacune avec un seul mot d'art. Je souhaite aligner le mot art sur le centre absolu de la diapositive. le code que j'ai essayé est:Comment vba peut-elle être utilisée pour changer les positions verticales et horizontales d'objets, comme WordArt, dans PowerPoint?

Option Explicit 

Sub format() 

    Dim sl As Slide 
    Dim ob As Object 

    For Each sl In ActivePresentation.Slides 

     For Each ob In sl.Shapes 
      With ob.TextFrame 
       ' .TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignCenter 
       ' .TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignMiddle 
       .HorizontalAnchor = msoAnchorCenter 
       .VerticalAnchor = msoAnchorMiddle 

      End With 

     Next ob 

    Next sl 

End Sub 

Répondre

0

Peut-être cela aidera-t-il.

Option Explicit 

Sub format() 

Dim sl As Slide 

    For Each sl In ActivePresentation.Slides 
     sl.Shapes.Range.Align msoAlignCenters, msoTrue 

     sl.Shapes.Range.Align msoAlignMiddles, msoTrue 
    Next sl 

End Sub 
+0

Merci Je vais essayer la prochaine fois que j'en ai besoin. –

+0

Ça a marché un charme. Je vous remercie. –