[尝试创建宏以快速输入项目名称以创建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
您可以通过DESIGN属性访问其他母版:https://docs.microsoft.com/en-us/office/vba/api/powerpoint.design
此代码应使您入门。如果您有任何问题,请提供反馈。(缩进缩进,以利于审稿人更好地理解):
Dim myValue As Variant
Dim sld As Slide
'Insert a Design Variable
Dim oMaster As Design
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.HeadersFooters
'Add name to slide master footer
With mySlidesHF
.Footer.Visible = True
.Footer.Text = myValue + " | Confidential © 2020"
.SlideNumber.Visible = True
End With
'Another approach would be to change the footer on each slide manually
For Each sld In ActivePresentation.Slides
With sld.HeadersFooters
.Footer.Visible = True
.Footer.Text = myValue + " | Confidential © 2020"
.SlideNumber.Visible = True
End With
Next
Next 'oMaster
我能够通过为每个主幻灯片中的布局添加第二个嵌套循环来更新所有主幻灯片/布局:
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