使用VBA从PowerPoint演示文稿中提取注释
PowerPoint演示文稿中的注释是一种方便的方式,用于记录和分享关于幻灯片的信息。以下是使用VBA从PowerPoint演示文稿中提取注释的方法:
Sub ExtractComments()
Dim pptSlide As Slide
Dim pptShape As Shape
Dim xlApp As Object
Dim xlWB As Object
Dim xlWS As Object
Dim i As Long
'创建一个新的Excel工作簿并设置对象变量
Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Add
Set xlWS = xlWB.Worksheets(1)
'遍历每个幻灯片
For Each pptSlide In ActivePresentation.Slides
i = i + 1
xlWS.Cells(i, 1) = "幻灯片 " & i
xlWS.Cells(i, 2) = pptSlide.Name
'遍历每个幻灯片上的形状
For Each pptShape In pptSlide.Shapes
If pptShape.HasTextFrame Then
If pptShape.TextFrame.HasText Then
xlWS.Cells(i, 3) = pptShape.TextFrame.TextRange
End If
End If
Next pptShape
Next pptSlide
'调整列宽
xlWS.Columns("A:C").EntireColumn.AutoFit
'显示Excel工作簿
xlWB.SaveAs "C:\Temp\SlideComments.xlsx"
xlApp.Visible = True
End Sub
注意:请确保在运行代码之前已经保存PowerPoint演示文稿。如果没有保存,代码可能会引用错误的文件路径。
领取专属 10元无门槛券
手把手带您无忧上云