gpt4 book ai didi

VBA一次性删除所有幻灯片

转载 作者:行者123 更新时间:2023-12-02 10:50:01 25 4
gpt4 key购买 nike

我找到了一段代码,可以一张一张地删除除事件幻灯片(索引1)之外的所有ppt幻灯片。但是,任何人都可以帮助我重写这段代码,以便一键操作该代码。我不想循环播放每张幻灯片,因为大约有 300 张幻灯片需要删除。这是我的代码:

Sub Deleteslides()

'This deletes all slides except Active Main one.

Dim Pre As Presentation
Set Pre = ActivePresentation
Dim x As Long
For x = Pre.Slides.Count To 2 Step -1
Pre.Slides(x).delete
Next x

End Sub

最佳答案

Sub Deleteslides()

Dim Pre As Presentation, arr(), x As Long, n As Long
Set Pre = ActivePresentation
ReDim arr(0 To Pre.Slides.Count - 2)
n = 0
For x = Pre.Slides.Count To 2 Step -1
arr(n) = x
n = n + 1
Next x
Pre.Slides.Range(arr).Delete

End Sub

关于VBA一次性删除所有幻灯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38863450/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com