VBA:如果幻灯片可见,则为幻灯片编号 [英] VBA : Number the slide if they are visible

查看:80
本文介绍了VBA:如果幻灯片可见,则为幻灯片编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有隐藏幻灯片的 PowerPoint 演示文稿.

I have a powerpoint presentation with hidden slides.

我只想给可见的幻灯片编号.

I want to number only the visible slides.

我得到了这个代码:

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 成员 (这是MSDN所说的)

I don't understand why vba doesn't recognise the HeaderFooter member (here is what MSDN says)

你能帮我弄清楚哪里出了问题吗?

Can you help me figure out what seems to be wrong?

推荐答案

MSDN 示例,正如经常发生的那样,充其量只是半准确.如果页脚对象不可见,则尝试为其分配文本会导致您看到的错误.这是您的代码的一个小修改:

The MSDN example, as is so often the case, is half-accurate at best. If the Footer object isn't visible, attempting to assign text to it results in the error you're seeing. Here's a slight mod to your code that works:

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

这篇关于VBA:如果幻灯片可见,则为幻灯片编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆