2010-06-01 66 views
4

我有很多演示文稿需要在我的公司之外共享,我需要一種方法來循環播放所有演講者備註並自動刪除它們。有沒有辦法在VBA中做到這一點?我搜索了這個,但似乎無法找到任何東西。從演示文稿中刪除演講者備註編程

回答

5

This guy寫了一個腳本,用於從目錄中的所有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 
+0

這是完美的,正是我所需要的! – Meihua 2010-06-02 20:40:22

+0

然後,您應該通過單擊左側空心複選標記來接受此答案。 – BenV 2010-06-02 21:00:01

+0

哦,對不起。我剛剛做完。再次感謝! – Meihua 2010-06-03 00:04:29