首页 > 解决方案 > 在文本占位符中替换和定位文本

问题描述

该代码替换了我的字体大小。

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

如何定位我的文本支架?

标签: vbapowerpoint

解决方案


尝试以下操作:

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

推荐阅读