【发布时间】:2017-11-17 03:49:48
【问题描述】:
我想打开当前文件夹中的每个 PowerPoint (*.pptx) 并清除所有图像和文本框的幻灯片母版,然后保存。
(它说我的帖子主要是代码,所以我需要添加更多细节,所以这是乔治华盛顿的一句话,“如果你尊重自己的声誉,就与优秀的人交往;因为独处比独处好在坏公司”)
新代码
Sub DeleteSlideMasterShapes()
Dim i As Long
Dim shp As Shape
With ActivePresentation
For i = .Designs.Count To 1 Step -1
For Each shp In .Designs(i).SlideMaster.Shapes
shp.Delete
Next
Next i
End With
End Sub
Sub loopFiles()
Dim fso As New FileSystemObject
Dim fil As File
Dim fold As Folder
Dim yourfolder As String
Set fold = fso.GetFolder(Application.ActivePresentation.Path)
For Each fil In fold.Files
If InStr(1, fil.Name, ".pptx") > 0 Then
Application.Presentations.Open fil.Path
Call DeleteSlideMasterShapes
ActivePresentation.Save
ActivePresentation.Close
End If
Next fil
End Sub
【问题讨论】:
-
您至少需要 1 个幻灯片母版。您不能删除所有幻灯片母版。如果您尝试删除最后一个,则会引发错误。这就像试图删除工作簿中的所有工作表。关于清除SM,你能解释一下你到底想达到什么目的吗?
-
我的幻灯片母版在标题中包含图像和文本框,我想清除它们当前包含的信息
标签: vba loops slide powerpoint