使用VBA从PowerPoint演示文稿中提取注释 [英] Extracting comments from a PowerPoint presentation using VBA
问题描述
我有一个PowerPoint,其中包含约50张幻灯片。每个幻灯片可能有1条或更多条注释,这些注释是由reviwer提供的(使用insert-> comment菜单完成)。
I have a PowerPoint which contains around 50 slides. Each slide might have 1 or more comments provided by the reviwer (done using insert->comment menu).
我正在尝试将注释以编程方式导出到文本文件中使用以下VBA代码:
I am trying to get the comments programatically exported into a text file using this VBA code:
Sub ConvertComments()
''# Converts new-style comments to old
Dim oSl As Slide
Dim oSlides As Slides
Dim oCom As Comment
Set oSlides = ActivePresentation.Slides
For Each oSl In oSlides
For Each oCom In oSl.Comments
''# write the text to file : (oCom.Text)
WriteToATextFile oCom.Author, <what needs to come here>, oCom.Text
Next oCom
Next oSl
End Sub
在上面的代码中,我还需要提供注释上下文,并将其写入文本文件(选择并评论了幻灯片中的哪一行)
In the above code, I need to provide the comment context as well to be written to a text file (which line in the slide was selected and commented upon)
问题:是这样吗?可以使用任何属性获取此信息吗?
Question: Is there any attribute I can use to get this info?
推荐答案
像这样:
Sub ConvertComments()
''# Converts new-style comments to old
Dim oSl As Slide
Dim oSlides As Slides
Dim oCom As Comment
Dim oShape As Shape
Open "filename.txt" For Output As 1
Set oSlides = ActivePresentation.Slides
Dim myContext As String
For Each oSl In oSlides
For Each oCom In oSl.Comments
myContext = ""
For ShapeIndex = oCom.Parent.Shapes.Count To 1 Step -1
myContext = myContext & oCom.Parent.Shapes(ShapeIndex).AlternativeText & " "
Next
Write #1, oCom.Author & ";" & myContext & ";" & oCom.Text
Next oCom
Next oSl
Close 1
End Sub
主要部分是循环通过注释父级的所有形状。
The main part is about the loop thru all shapes parent to the comment.
这篇关于使用VBA从PowerPoint演示文稿中提取注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!