首页 > 解决方案 > 如何将 Textshape 1 指定为标题?

问题描述

使用 Office 2016 PPT,在共享 PPT 文件并将其取回后,它现在保留了幻灯片上的标题,但它们现在是“TextShape 1”,位于正确的位置(幻灯片顶部),并且不显示为标题在大纲视图等

仅重置幻灯片会覆盖空框。

如何在每张幻灯片上制作“TextShape 1”以将其视为相应幻灯片的标题?重新定义?添加一个内容为“TextShape 1”的新标题框,并删除旧框?

标签: vbapowerpoint

解决方案


感谢您的意见。

作为一个 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

推荐阅读