VBA :如果幻灯片可见则对其进行编号
VBA : Number the slide if they are visible
我有一个隐藏幻灯片的 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)
你能帮我找出问题所在吗?
MSDN 示例,通常情况下,充其量是半准确的。如果 Footer 对象不可见,尝试向其分配文本会导致您看到的错误。这是对您有效的代码的轻微 mod:
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
我有一个隐藏幻灯片的 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)
你能帮我找出问题所在吗?
MSDN 示例,通常情况下,充其量是半准确的。如果 Footer 对象不可见,尝试向其分配文本会导致您看到的错误。这是对您有效的代码的轻微 mod:
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