【问题标题】:Replace and position text in text placeholder在文本占位符中替换和定位文本
【发布时间】:2019-08-05 17:45:19
【问题描述】:

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

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

如何定位我的文本支架?

【问题讨论】:

    标签: vba powerpoint


    【解决方案1】:

    尝试以下方法:

    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
    

    【讨论】:

    • 感谢您的帮助。我的文本左侧还有一些额外的空格需要删除我正在尝试使用 .wordwrap 和自动调整来删除它,但不会删除额外的空格。如果您能对此提供帮助,我们将不胜感激。谢谢
    • @DilpreetSingh,在 aShape.Top = 23 命令之前添加 aShape.TextFrame.TextRange.Text = Trim(aShape.TextFrame.TextRange.Text)。如果我发布的内容回答了您的问题,那么您应该将其标记为已回答。
    • 嗨 Michaels ,但是提到的代码不起作用并且在运行后出错
    • 我目前正在使用此代码来建立 .但是我刚刚发现文本占位符中的某些文本有一些缩进,应该是在文本之前 = 0 厘米特殊 = 无对齐 = 左请帮助将相同的内容合并到子例程中以建立相同的内容。
    猜你喜欢
    • 2013-12-20
    • 1970-01-01
    • 2010-09-29
    • 2012-12-07
    • 2022-11-25
    • 1970-01-01
    • 2020-11-02
    • 2017-02-16
    相关资源
    最近更新 更多