以编程方式从演示文稿中删除演讲者备注

Mei*_*hua 4 powerpoint powerpoint-vba

我有很多演示文稿需要在我公司之外共享,我需要一种方法来遍历所有演讲者笔记并自动删除它们.有没有办法在VBA中执行此操作?我在搜索这个但似乎找不到任何东西.

Ben*_*enV 5

这个人写了一个脚本,从目录中的所有PowerPoint文件中删除说话者笔记.您应该能够根据自己的需要进行调整.

Sub RemoveSpeakerNotes()
  Set objPPT = CreateObject("PowerPoint.Application")
  objPPT.Visible = True
  strComputer = "."
  Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  Set FileList = objWMIService.ExecQuery _
    ("ASSOCIATORS OF {Win32_Directory.Name='E:\DirectoryContainingPresentations'} Where " _
    & "ResultClass = CIM_DataFile")
  For Each objFile In FileList
    If objFile.Extension = "pptx" Or objFile.Extension = "ppt" Then
      Set objPresentation = objPPT.Presentations.Open(objFile.Name)
      Set colSlides = objPresentation.Slides
      On Error Resume Next
      For Each objSlide In colSlides
        objSlide.NotesPage.Shapes(2).TextFrame.TextRange = ""
      Next
      objPresentation.Save
      objPresentation.Close
    End If
  Next
  MsgBox ("Done")
End Sub
Run Code Online (Sandbox Code Playgroud)