2010-07-27 45 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

相關問題