[尝试创建宏以快速输入项目名称以创建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
这是您的代码:
Sub footchange()
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
'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
Next 'oMaster
结束子