Замените текстовое поле заполнителем (заголовок или текст) - PullRequest
0 голосов
/ 13 июля 2020
• 1000 с настоящими заполнителями вручную было больно.

Итак, я пришел с этим скриптом, чтобы ускорить процесс.

Если у кого-то есть лучший подход, приветствую.

1 Ответ

0 голосов
/ 13 июля 2020

Пришлось искать обходной путь, чтобы получить объект customlayout.

Некоторые вещи отсутствуют, например обработка ошибок.

Чтобы проверить это, скопируйте текстовое поле в макет слайд-мастера слайд, выберите его и запустите макрос ReplaceWithPHTitle

Option Explicit

Public Sub ReplaceWithPHTitle()

    ReplaceTexboxWithPlaceholder ppPlaceholderTitle

End Sub

Public Sub ReplaceWithPHBody()

    ReplaceTexboxWithPlaceholder ppPlaceholderBody

End Sub

Private Sub ReplaceTexboxWithPlaceholder(ByVal placeholderType As PpPlaceholderType)

    Dim targetLayout As CustomLayout
    Dim activeShape As Shape
    Dim newPlaceHolder As Shape
    
    Set activeShape = ActiveWindow.Selection.ShapeRange(1)
    Set targetLayout = activeShape.Parent
    
    Set newPlaceHolder = targetLayout.Shapes.AddPlaceholder(Type:=placeholderType, Left:=activeShape.Left, Top:=activeShape.Top, Width:=activeShape.Width + 15, Height:=activeShape.Height)
    
    With newPlaceHolder.TextFrame

        .TextRange.Font.Name = activeShape.TextFrame.TextRange.Font.Name
        .TextRange.Characters.Font.Color.RGB = activeShape.TextFrame.TextRange.Characters.Font.Color.RGB
        .TextRange.Font.Size = activeShape.TextFrame.TextRange.Font.Size
        .TextRange.Font.Bold = activeShape.TextFrame.TextRange.Font.Bold
        .TextRange.ParagraphFormat.Bullet.Type = activeShape.TextFrame.TextRange.ParagraphFormat.Bullet.Type
        .TextRange.ParagraphFormat.SpaceWithin = activeShape.TextFrame.TextRange.ParagraphFormat.SpaceWithin
        .TextRange.ParagraphFormat.Alignment = activeShape.TextFrame.TextRange.ParagraphFormat.Alignment
        .TextRange.ParagraphFormat.SpaceBefore = activeShape.TextFrame.TextRange.ParagraphFormat.SpaceBefore
        .TextRange.ParagraphFormat.SpaceAfter = activeShape.TextFrame.TextRange.ParagraphFormat.SpaceAfter
        .TextRange.ParagraphFormat.BaseLineAlignment = activeShape.TextFrame.TextRange.ParagraphFormat.BaseLineAlignment
        .TextRange.Text = activeShape.TextFrame.TextRange.Text
    End With
    
    With newPlaceHolder.TextFrame2
        .TextRange.Font.Spacing = activeShape.TextFrame2.TextRange.Font.Spacing
    End With
    
    newPlaceHolder.ZOrder msoSendToBack
    newPlaceHolder.Select
    
End Sub

Приветствуются также любые улучшения.

...