VBA代码替换和放置文本在文本放置位置中的位置

时间:2019-06-28 11:00:02

标签: vba powerpoint powerpoint-vba

上面的代码替换了我的字体Size,除此之外,我需要对齐下面提到的position。请帮助我合并此代码

Sub changeFont()
For Each aSlide In ActivePresentation.Slides
For Each aShape In aSlide.Shapes
If aShape.Type = msoTextBox Then
If aShape.TextFrame.HasText Then
If aShape.TextFrame.TextRange.Font.Name = "Franklin Gothic Demi" Then
If aShape.TextFrame.TextRange.Font.Size = 40 Then
      aShape.TextFrame.TextRange.Font.Size = Replace(aShape.TextFrame.TextRange.Font.Size, 40, 25)
End If
End If
End If

End If
Next
Next
End Sub

代码成功运行以获取所需的结果。但是我需要将文本框对齐

.Top=23
.Left=44
.Height=44

请帮助我处理该子例程,因为我需要放置文本支架

感谢期待

1 个答案:

答案 0 :(得分:0)

尝试以下操作:

Sub changeFont()
    Dim aSlide As Slide, aShape As Shape
    For Each aSlide In ActivePresentation.Slides
        For Each aShape In aSlide.Shapes
            If aShape.Type = msoTextBox Then
                If aShape.TextFrame.HasText Then
                    If aShape.TextFrame.TextRange.Font.Name = "Franklin Gothic Demi" Then
                        If aShape.TextFrame.TextRange.Font.Size = 40 Then
                              aShape.TextFrame.TextRange.Font.Size = Replace(aShape.TextFrame.TextRange.Font.Size, 40, 25)
                              aShape.Top = 23
                              aShape.Left = 44
                              aShape.Height = 44
                        End If
                    End If
                End If
            End If
        Next
    Next
End Sub