Vba 仅从激活的幻灯片中删除动画
我正试图通过powerpoint中的vbscript删除动画。 但它应该只从选定的幻灯片中删除,而不是从所有幻灯片中删除 我尝试了一些代码,但它正在从示例代码下面共享的所有幻灯片中删除,有人能帮我解决这个问题吗Vba 仅从激活的幻灯片中删除动画,vba,powerpoint,Vba,Powerpoint,我正试图通过powerpoint中的vbscript删除动画。 但它应该只从选定的幻灯片中删除,而不是从所有幻灯片中删除 我尝试了一些代码,但它正在从示例代码下面共享的所有幻灯片中删除,有人能帮我解决这个问题吗 Sub RemoveAllAnimations() 'PURPOSE: Remove All PowerPoint Animations From Slides 'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault Dim sld As
Sub RemoveAllAnimations()
'PURPOSE: Remove All PowerPoint Animations From Slides
'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault
Dim sld As Slide
Dim x As Long
Dim Counter As Long
'Loop Through Each Slide in ActivePresentation
For Each sld In ActivePresentation.Slides
'Loop through each animation on slide
For x = sld.TimeLine.MainSequence.Count To 1 Step -1
'Remove Each Animation
sld.TimeLine.MainSequence.Item(x).Delete
'Maintain Deletion Stat
Counter = Counter + 1
Next x
Next sld
'Completion Notification
MsgBox Counter & " Animation(s) were removed from you PowerPoint presentation!"
End Sub
它将仅为选定幻灯片从所有幻灯片中删除动画:
Sub RemoveAllAnimations()
Dim sld As Slide
Dim x As Long
Dim Counter As Long
Set sld = ActiveWindow.View.Slide
For x = sld.TimeLine.MainSequence.Count To 1 Step -1
sld.TimeLine.MainSequence.Item(x).Delete
Counter = Counter + 1
Next x
Set sld = Nothing
MsgBox Counter & " Animation(s) were removed from your PowerPoint presentation!"
End Sub
你的第一个For循环是通过每张幻灯片。无论您从何处提取代码,都有人在目的注释中明确说明了这一点。您可能需要编写更多代码或更改现有代码,以选择要从中删除动画的幻灯片。您发布的代码不是VBScript,但可能是在Powerpoint中使用的VBA(Visual Basic for Applications)。感谢John Korchok,它为我工作,是否有其他代码用于从选定幻灯片中删除动画。提前谢谢你的帮助这个答案应该对你有帮助