我有几个开放的PPT演示文稿。我有一个宏,它可以在我选择作为活动演示文稿的任何一个上工作得很好。我应该使用什么代码1.保存活动演示文稿。2.关闭活动演示文稿。3.转到任何打开的PPT演示文稿。4.运行宏,保存,关闭。5.冲洗,重复,直到宏在所有演示文稿中运行并将其关闭。
发布于 2019-08-24 03:35:25
这有点杂乱无章。将第4行编辑为包含宏的启用宏的演示文稿的实际名称。Save/Close循环运行两次,第一次是为了捕获在包含宏的循环之后打开的演示文稿,另一次是为了捕获之前打开的演示文稿。然后,带有宏的演示文稿在结束时被保存为关闭:
Sub CloseAll()
Dim oPresentation As Presentation, ThisPresentation As Presentation
Dim ThisFile$
ThisFile$ = "CloseAll.pptm"
Set ThisPresentation = Application.Presentations(ThisFile$)
For Each oPresentation In Application.Presentations
If oPresentation.Name = ThisPresentation.Name Then
Else
With oPresentation
.Save
.Close
End With
End If
Next oPresentation
For Each oPresentation In Application.Presentations
If oPresentation.Name = ThisPresentation.Name Then
Else
With oPresentation
.Save
.Close
End With
End If
Next oPresentation
With ThisPresentation
.Save
.Close
End With
Exit Sub
End Subhttps://stackoverflow.com/questions/57627256
复制相似问题