VBA:如果幻灯片可见,请为幻灯片编号

问题描述 投票:1回答:1

我有一个隐藏幻灯片的powerpoint演示文稿。

我想只对可见幻灯片进行编号。

我得到了这段代码:

Sub Numerotation()
Dim x As Integer
Dim diapo As Slide
For Each diapo In ActivePresentation.Slides
  If diapo.SlideShowTransition.Hidden = False Then
    x = x + 1
    diapo.HeadersFooters.Footer.Text = x
  Else
    diapo.HeadersFooters.Footer.Text = ""
  End If
Next
End Sub

我收到了这个错误:

Execution Error : '-2147188160 (80048240)':
HeaderFooter (unknown member) : Invalid request

我不明白为什么vba不能识别HeaderFooter成员(here is what MSDN says

你能帮我搞清楚看似错的吗?

vba powerpoint powerpoint-vba
1个回答
2
投票

MSDN示例(通常是这种情况)充其量只是半精确。如果页脚对象不可见,则尝试为其指定文本会导致您看到的错误。以下是适用于您的代码的一个小模块:

Sub Numerotation()
Dim x As Integer
Dim diapo As Slide
For Each diapo In ActivePresentation.Slides
  If diapo.SlideShowTransition.Hidden = False Then
    x = x + 1
    diapo.HeadersFooters.Footer.Visible = True
    diapo.HeadersFooters.Footer.Text = CStr(x)
  Else
    diapo.HeadersFooters.Footer.Visible = False
  End If
Next
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.