【问题标题】:What are Shape.TextFrame and .TextRange in PowerPoing VBA?PowerPoint VBA 中的 Shape.TextFrame 和 .TextRange 是什么?
【发布时间】:2016-01-22 15:41:07
【问题描述】:

我正在寻找信息来帮助我更好地理解 PowerPoing VBA 中的“.TextFrame”和“.TextRange”对象。有人可以帮忙吗?我已经查看了 MSDN 上的内容,但一直对那里的文档感到失望。

【问题讨论】:

  • 请查看帮助中心以及 Stack Overflow 的 on topic 是什么 - 这个问题是题外话,因为它要求推荐一本书、工具或软件图书馆。
  • 我已编辑您的问题以更好地符合网站指南,因为 Steve Rindsberg 的回复是网站的重要信息,不应丢失。我相信它也回答了你真正的问题......
  • 谢谢你,@CindyMeister

标签: vba powerpoint textrange


【解决方案1】:

形状是 PPT 幻灯片、母版、布局、注释页面的基本构建块;他们身上的一切都是一个形状。

某些形状(例如线条)不能包含文本。那些可以包含文本的有一个 TextFrame。如果 Shape.TextFrame 包含文本,那么您可以使用 Shape.TextFrame.TextRange 来访问(设置/读取)TextFrame 中所有文本的属性。其他方法也返回一个 .TextRange,它可能是 .TextFrame 中文本的某个子集。

简单示例:

Sub DoSomethingUseless()

Dim oSh as Shape
Dim oSl as Slide

For Each oSl in ActivePresentation.Slides

For Each oSh in oSl.Shapes
   If oSh.HasTextFrame Then
      If oSh.TextFrame.HasText Then
         Debug.Print oSh.TextFrame.TextRange.Text
      End If
   End If
Next   ' Shape

Next   ' Slide

End Sub

【讨论】:

    猜你喜欢
    • 2017-08-25
    • 1970-01-01
    • 2012-06-30
    • 1970-01-01
    • 2011-04-12
    • 1970-01-01
    • 1970-01-01
    • 2012-04-02
    • 1970-01-01
    相关资源
    最近更新 更多