2016-09-19 1 views
0

поэтому у меня есть эта строка кода, которая отлично работает всего за 1 ppt-файл.Center top most textframe VBA powerpoint

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.ParagraphFormat.Alignment=ppAlignCenter 

Как я могу сделать эту работу для всех файлов PowerPoint в той же папке с VBA? Так что он знает, что он выбирает верхнюю часть TextFrame, а затем AlignCenters.

Или даже когда все ППЦ открыты, если это проще ..

ответ

0

Это будет выбрать форму, которая расположена ближе к верхней части слайда:

Option Explicit 

' Selects the shape that support text which is closest to the top of the slide 
' Written by Jamie Garroch of YOUpresent Ltd (http://youpresent.co.uk) 
Sub SelectHigestTextShape() 
    Dim oSld As Slide 
    Dim oShp As Shape, oShpTop As Shape 
    Dim sShpTop As Single 

    On Error Resume Next 
    Set oSld = ActiveWindow.View.Slide 
    If Err Then Exit Sub 
    On Error GoTo 0 

    ' Set the top to the bottom of the slide 
    sShpTop = ActivePresentation.PageSetup.SlideHeight 

    ' Check each shape on the slide is positioned above the stored position 
    ' Shapes not supporting text and placeholders are ignored 
    For Each oShp In oSld.Shapes 
    If oShp.Top < sShpTop And oShp.HasTextFrame And Not oShp.Type = msoPlaceholder Then 
     sShpTop = oShp.Top 
     Set oShpTop = oShp 
    End If 
    Next 

    ' Select the topmost shape 
    If Not oShpTop Is Nothing Then oShpTop.Select msoTrue 

    ' Clean up 
    Set oSld = Nothing 
    Set oShp = Nothing 
    Set oShpTop = Nothing 
End Sub 
+0

Благодаря это работает, но мне кажется, что он не работает, когда я говорю, что он должен делать это для всех открытых книг. – Probs

 Смежные вопросы

  • Нет связанных вопросов^_^