我有一个隐藏幻灯片的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)
你能帮我弄清楚什么是错的吗?
答案 0 :(得分: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