2010-07-27 79 views
5

我有一个包含大约50张幻灯片的PowerPoint。每张幻灯片可能有一个或多个评论由reviwer提供(使用insert-> comment菜单完成)。使用VBA从PowerPoint演示文稿提取评论

我试图让编程导出到使用这个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 

在上面的代码,我需要提供意见上下文中还写入一个文本文件(幻灯片中的哪一行被选中并加以评论)

问:是否有任何属性可用于获取此信息?

+0

你是什么意思与“评论上下文”?问题也是如何写入VBA中的文本文件,还是仅仅关于“评论上下文”。我可以为您提供如何编写文本文件的代码,如果这有帮助,也许如果您澄清“评论上下文”,那么这也将与它。 – hol 2010-07-27 11:16:51

+0

我的评论上下文如下: 假设ppt 中有一行文字,审核人选中它并点击插入 - >评论菜单 我需要获取被选中并在 – balalakshmi 2010-07-27 11:28:07

回答

4

像这样:

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 

主要部分是有关环路直通的所有形状父母的意见。

+0

上评论过的行成功了! 谢谢 – balalakshmi 2010-07-28 04:44:38

+0

任何方式获得幻灯片编号以及? – Alex 2015-06-17 09:38:10

+0

@hol:我试过这个解决方案,我发现这个代码片段没有在同一张幻灯片中标识回复评论?你能帮我回复评论吗? – 2016-10-31 07:23:10