[英]Extracting comments from a PowerPoint presentation using VBA
我有一個包含大約 50 張幻燈片的 PowerPoint。 每張幻燈片可能有評論者提供的 1 條或多條評論(使用插入->評論菜單完成)。
我正在嘗試使用此 VBA 代碼以編程方式將評論導出到文本文件中:
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
在上面的代碼中,我需要提供評論上下文以及寫入文本文件(幻燈片中的哪一行被選中並評論)
問題:我可以使用任何屬性來獲取此信息嗎?
像這樣:
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
主要部分是關於通過所有形狀的循環到注釋的父級。
不要忘記回復!
添加到 Todd Main 上面的代碼中:
Sub ConvertComments()
''# Converts new-style comments to old >>> and include the Replies.
Dim oSl As Slide, oSlides As Slides
Dim oCom As Comment, Reply 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
GoSub WriteComment2File
'Don't forget the replies!
For Each Reply In oCom.Replies 'NOTE: Replies are just Comment objects
GoSub WriteComment2File
Next Reply
Next oCom
Next oSl
Close 1
Exit Sub '________________
WriteComment2File:
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
Return
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.