更新所有幻灯片母版和版式页脚 [英] Update all slide master's and layout's footers

查看:0
本文介绍了更新所有幻灯片母版和版式页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在尝试创建宏以快速输入项目名称到ppt页脚。我只能让顶级幻灯片母版接受输入的标题。我尝试使用新的页脚信息循环浏览其他幻灯片母版版面,但在For循环中将文本写入页脚的行上不断出现错误


    Sub footchange()

    Dim myValue As Variant
    Dim sld As Slide

    myValue = InputBox("Enter Presentation Name")

    Set mySlidesHF = ActivePresentation.SlideMaster.HeadersFooters

    'Add name to slide master footer
    With mySlidesHF
        .Footer.Visible = True
        .Footer.Text = myValue + "    |   Confidential © 2020"
        .SlideNumber.Visible = True  
    End With

    'Add name to slide master layouts footers
    For Each sld In ActivePresentation.Slides
       With sld.HeadersFooters
            .Footer.Visible = True 
            .Footer.Text = myValue + "    |   Confidential © 2020"
            .SlideNumber.Visible = True
        End With
    Next

推荐答案

我能够通过为每个母版幻灯片中的版面添加第二个嵌套循环来更新所有母版幻灯片/版面:

Sub footchange()

Dim myValue As Variant
Dim sld As Slide

'Add design and layout variables
Dim oMaster As Design
Dim cLay As CustomLayout

myValue = InputBox("Enter Presentation Name")

'Just to show you how many Masters you have
Debug.Print ActivePresentation.Designs.Count

'Loop through them
For Each oMaster In ActivePresentation.Designs

'Use actual Design
Set mySlidesHF = oMaster.SlideMaster
Set myLayoutsHF = oMaster.SlideMaster.CustomLayouts


'Add name to slide master footer
With mySlidesHF.HeadersFooters
    .Footer.Visible = True
    .Footer.Text = myValue + "    |   Confidential © 2020"
    .SlideNumber.Visible = True
End With

'Add name to layouts
For Each cLay In myLayoutsHF
    With cLay.HeadersFooters
        .Footer.Visible = True
        .Footer.Text = myValue + "    |   Confidential © 2020"
        .SlideNumber.Visible = True
    End With
Next cLay

Next oMaster


End Sub

这篇关于更新所有幻灯片母版和版式页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆