首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PPT =使用节名称

PPT =使用节名称
EN

Stack Overflow用户
提问于 2018-12-29 01:29:22
回答 1查看 1.4K关注 0票数 0

有没有办法在每张幻灯片上的文本框中显示节名称,以便可以传达给观众?如下所示:https://answers.microsoft.com/en-us/msoffice/forum/all/ppt-using-section-names-in-footer/2b844798-2afa-4216-9ba5-5d066ac4dcca,但我不能使用页脚,因为它已经在其他地方使用了。

编辑:@ Steve Rindsberg -非常感谢你的回答。

(对不起,我犯了错误。我是一个VBA的初学者(因为两个星期-但很多小时的…)。

以下是我的代码:首先,我尝试了以下操作:

我将一个文本框作为占位符添加到一个文本为"Section#“的SlideMaster.CustomLayout中。

代码语言:javascript
复制
Sub AddTextboxToSlidemaster()
Dim shp As Shape
On Error Resume Next
Set shp = Application.ActivePresentation.Designs(1).SlideMaster.CustomLayouts(1).Shapes.AddPlaceholder(ppPlaceholderObject,  _
Left:=223.75, Top:=9#, Width:=453.62, Height:=12.18898)
With shp
    shp.Tags.Add "TEXT", "Section#"  'this seems to be unnecessary
       With .TextFrame
            .TextRange.Text = "Section#"
       With .TextRange
                .Font.Size = 12
                .Font.name = "Verdana"
                .Font.Color.RGB = RGB(7, 37, 62)
                .ParagraphFormat.Bullet = msoFalse
           End With
       End With
    End With
End Sub  

然后,我将这个占位符/文本框复制到一些相关的自定义布局中。接下来,我添加了一些带有这些自定义布局之一的幻灯片(在slideView中)。所以我在一些幻灯片上有这个占位符/文本框。

下一步:我在所有幻灯片中搜索文本"Section#“,并用" text”标记这些占位符,值为"Section#":

代码语言:javascript
复制
Sub FindTextSelectionAndTag()
For Each sld In Application.ActivePresentation.Slides
    For Each shp In sld.Shapes
        If shp.HasTextFrame Then
            Set txtRng = shp.TextFrame.TextRange
            Set foundText = txtRng.Find(FindWhat:="Section#")
            Do While Not (foundText Is Nothing)
                With foundText
                shp.Tags.Add "TEXT", "Section#"
        Set foundText = _
                        txtRng.Find(FindWhat:="Section#", _
                        After:=.Start + .Length - 1)
              End With
            Loop
        End If
    Next
Next
End Sub 

但幻灯片上的占位符不接受此标记。

因此,我没有这样做,而是在一些相关幻灯片上直接设置了文本框“Section#”-正如您所建议的-然后运行宏来标记文本框:

"Sub FindTextSelectionAndTag()“,如上所述。

最后,我创建了这个宏,它将当前部分带到分类/标记文本框中。

代码语言:javascript
复制
Sub AbschnittHeader()
  Dim sld As Slide
  Dim shp As Shape
  Dim b_found As Boolean
    If ActivePresentation.SectionProperties.Count > 0 Then
      For Each sld In ActivePresentation.Slides
      For Each shp In sld.Shapes
  If shp.Tags("TEXT") = "Section#" Then _
  shp.TextFrame.TextRange = 
 ActivePresentation.SectionProperties.name(sld.sectionIndex)
     Next shp
   Next sld
 End If
End Sub

到目前为止,这是可行的。

我会要求在该代码中进行可能的优化-我有一个问题,在theMasterslide.customlayout上添加占位符有什么问题。有没有办法做到这一点--因为我认为这种方式会更舒适。为了这个目的,这是不可能的。

我还想将PowerPoint文件(ActivePresentation)的名称添加到文本框中的部分,如下所示(但我不知道如何添加):

powerpoint文件名称| sld.sectionIndex

例如(pptFile名称: Marketing):

市场营销|第1章简介

市场营销|第2章…

我很感谢你的建议。

EN

回答 1

Stack Overflow用户

发布于 2019-01-05 23:21:39

非常感谢。下面是我的最终解决方案:

首先是我的问题中描述的Sub AddTextboxToSlides() --但不是针对母版的,而是针对几张幻灯片的--然后使用以下几行代码实现Sub AbschnittHeader() optional:

a.包含在文件名中

代码语言:javascript
复制
For Each shp In sld.Shapes
  If shp.Tags("TEXT") = "Section#" Then _
    shp.TextFrame.TextRange = ActivePresentation.FullName _
    & " | " & ActivePresentation.SectionProperties.name(sld.sectionIndex)

b.或包含在第一张幻灯片中的“文件标题”中:-)

代码语言:javascript
复制
For Each shp In sld.Shapes
  If shp.Tags("TEXT") = "Section#" Then _
    shp.TextFrame.TextRange = _
    ActivePresentation.Slides(1).Shapes.Title.TextFrame.TextRange.Text _
    & " | " & ActivePresentation.SectionProperties.name(sld.sectionIndex)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53962182

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档