Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-19-2023, 01:23 PM
amschaefer amschaefer is offline Parent/Child Comment Extract Windows 11 Parent/Child Comment Extract Office 2019
Novice
Parent/Child Comment Extract
 
Join Date: Oct 2023
Posts: 1
amschaefer is on a distinguished road
Default Parent/Child Comment Extract

I am trying to extract comments from a Word document into an Excel spreadsheet.



The goal is to extract a parent and child comment and place them in the same record and continue to iterate through the document.

For some reason the coding will populate a Child comment as a new record when only a parent comment should, and I'm looking to have that not happen.

Current code attached.

Any help is much appreciated!
Attached Files
File Type: txt Comment Extract 2023.10.18.txt (8.2 KB, 4 views)

Last edited by amschaefer; 10-19-2023 at 01:24 PM. Reason: Attaching code
Reply With Quote
  #2  
Old 10-19-2023, 11:41 PM
Guessed's Avatar
Guessed Guessed is offline Parent/Child Comment Extract Windows 10 Parent/Child Comment Extract Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I'm not seeing a better way to work out the parent/child relationship so I've done this kludgy method. You could adopt the same principle in your code.
If the comment doesn't have an ancestor then it must be a top level comment
Then use the Replies.Count to iterate through the replies

Code:
Sub aTest()
  Dim aCmt As Comment, sAuth As String, sReplies As String
  Dim i As Integer, aReply As Comment
  For Each aCmt In ActiveDocument.Comments
    If aCmt.Ancestor Is Nothing Then        'a top level comment
      Debug.Print aCmt.Author, aCmt.Done, aCmt.Range.Text, aCmt.Replies.Count
      If aCmt.Replies.Count > 0 Then
        For i = 1 To aCmt.Replies.Count
          Set aReply = aCmt.Replies(i)
          sReplies = sReplies & vbTab & aReply.Author & ": " & aReply.Range.Text & vbCr
        Next i
        Debug.Print sReplies
        sReplies = ""
      End If
    End If
  Next aCmt
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Tags
comment

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Schema Parent Child Extraction ChrisOK Excel Programming 0 11-16-2017 08:22 AM
Parent/Child Comment Extract Updating "Parent Phrase" to change all Child Phrases - (References, Fields, Headings?) tclass117 Word 1 11-18-2016 10:14 PM
Hilight Parent Folder when Child folder is allocated a new email brucemc777 Outlook 2 11-09-2016 09:14 AM
Parent/Child Comment Extract Advanced Content Control Problem, Making CC editable through child links not only parent Lance Dwight Word 1 10-15-2014 05:45 PM
Parent/Child Comment Extract How to insert a (balloon) comment and how to disable comment feature in Word2007? pstein Word 2 03-31-2012 05:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft