vba - 如何将 Textshape 1 指定为标题?
问题描述
使用 Office 2016 PPT,在共享 PPT 文件并将其取回后,它现在保留了幻灯片上的标题,但它们现在是“TextShape 1”,位于正确的位置(幻灯片顶部),并且不显示为标题在大纲视图等
仅重置幻灯片会覆盖空框。
如何在每张幻灯片上制作“TextShape 1”以将其视为相应幻灯片的标题?重新定义?添加一个内容为“TextShape 1”的新标题框,并删除旧框?
解决方案
感谢您的意见。
作为一个 vba-powerpoint 初学者,在集合和术语中找到自己的方式并不容易,而且肯定很耗时,但我为所呈现的有限问题编写了一个解决方案。
您可能认为您可以添加一个标题对象,但至少按照我尝试的方式,它抱怨当前幻灯片布局无法做到这一点。我不知道如何将文本框指定为标题。所以我使用vba将格式设置为Titleonly,用于没有幻灯片的幻灯片,将文本复制到其中,然后删除与新形状重叠的旧形状,如下所示:
Attribute VB_Name = "Module1"
Sub newtitles()
Dim s As Variant
For s = 1 To ActivePresentation.Slides.Count
If Not ActivePresentation.Slides(s).Shapes.HasTitle Then
ActivePresentation.Slides(s).Layout = ppLayoutTitleOnly
' adds a title placeholder too; could not .addtitle to slide without a title in format
ActivePresentation.Slides(s).Shapes.Title.TextFrame.TextRange.Text = ActivePresentation.Slides(s).Shapes(1).TextFrame.TextRange.Text
ActivePresentation.Slides(s).Shapes(1).Delete ' remove redundant box
End If 'about title
Next ' slides
End Sub
推荐阅读
- node.js - 如何在两个 MongoDB 数据库之间同步两个相同的集合?
- firebase - 一次 Firestore 事务中的 2 次更新
- javascript - 如何将数据从 Angular 表单发送到特定的“文件夹结构”到 Firebase?
- javascript - 带有 socket.io 的 WebRTC/nodejs 中的屏幕共享问题
- excel - 使用 Excel VBA 宏捕获
- rest-assured - 我想使用 java 放心地将嵌套的多个数组作为 json 对象发送
- python - 错误:无效文档:文档必须只有字符串键,键是..将熊猫多索引数据框插入到 mongodb
- javascript - 如何在胜利图表中显示尾随线
- r - 如何使通用 R 函数继承其输入的类?
- sql - 将行转换为涉及日期的列