2016-09-19 5 views
0

だから、私はちょうど1 pptファイルのためにうまく動作するこのコード行を持っています。センター最上部のテキストフレームVBAパワーポイント

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

私はこの作業をVBAの同じフォルダにあるすべてのパワーポイントファイルに対して行うことができますか?そのため、一番上のTextFrameを選択してからそれをAlignCentersにすることがわかります。

またはすべてのPPTが開いている場合でも、それは、これはスライドの先頭に最も近い位置される形状を選択します。..

答えて

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

関連する問題