+ Reply to Thread
Results 1 to 11 of 11

VBA Tracked Changes HELP

  1. #1
    Registered User
    Join Date
    02-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2007
    Posts
    6

    Question VBA Tracked Changes HELP

    Hi guys,

    I need your help here...

    i'm trying to create a VBA code to pull trakced changes from a document and display it in a newly created document.

    Does anyone know how i need to change this code so that it also picks up the insertions and deletions form header and footer of the document.

    the below code will extract only the insertions and deletions of main body but i've tried a few edits and nothing seems to work

    Thanks guys


    ------code-----

    Please Login or Register  to view this content.
    ------------------
    Last edited by arlu1201; 03-14-2013 at 03:39 AM. Reason: Use code tags in future.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: VBA Tracked Changes HELP

    A fairly simple approach is to delete everything that isn't a revision from the activedocument, then save it to a new document:
    Please Login or Register  to view this content.
    Note: the above code doesn't actually do the save part.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    02-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: VBA Tracked Changes HELP

    Many thanks for your help, however the above code dose not work its shows a compile error in 'For statement'

    i need a code that will extract footer, in my below code it was mention how to edit the code for footer reference but i am unable to make it ..

    ------code--------


    For Each oRevision In oDoc.Revisions
    Select Case oRevision.Type
    'Only include insertions and deletions
    Case wdRevisionInsert, wdRevisionDelete
    'In case of footnote/endnote references (appear as Chr(2)),
    'insert "[footnote reference]"/"[endnote reference]"
    With oRevision
    'Get the changed text
    strText = .Range.Text

    Set oRange = .Range
    Do While InStr(1, oRange.Text, Chr(2)) > 0
    'Find each Chr(2) in strText and replace by appropriate text
    i = InStr(1, strText, Chr(2))


    --------------

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: VBA Tracked Changes HELP

    Your initial post Asked:
    Does anyone know how i need to change this code so that it also picks up the insertions and deletions form header and footer of the document.
    The code I posted works fine for that.

    You latest post still refers to footers when, in fact, the issue is with footnotes and endnotes. It would be helpful if you were rather more precise about the terminology you use. Asking for help with one problem, then complaining the help provided doesn't work for something you didn't ask for help with isn't going to win you any friends.

    Footnote and endnote extraction poses quite a different problem, especially when it comes to how you might extract their tracked change content when their references are not themselves part of a tracked change (eg only a few words in a footnote have been changed, but the text to which the reference is attached hasn't been changed). If you can clarify your expectations in that regard, progress might be made.

  5. #5
    Registered User
    Join Date
    02-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: VBA Tracked Changes HELP

    sorry for the confusion..... but i need the code that will also extract the track changes form the header and footer. i.e. any insertion or deletion in the header and footer.

    the above code will extract track changes only form the main body of the document.....

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: VBA Tracked Changes HELP

    Have you actually tried the code I posted - as I posted it?

  7. #7
    Registered User
    Join Date
    02-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: VBA Tracked Changes HELP

    yes, i have tried but it shows the compile error. I have followed the below steps...

    1 - copied the above code and pasted it in MS word >> VBA >> New Module .... and then try to run the code.

    let me know if i have missed anything...

  8. #8
    Registered User
    Join Date
    02-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: VBA Tracked Changes HELP

    i tried to fix the problem with your code, if i mark one of the FOR LOOP statement as comment then the code works fine... however this code will delete everything that isn't a revision from the 'activedocument... but i need a code that will extract all the revisions from header and footer to a new document.

    see below code... i have marked comment one of the for loop [line number - 16]...

    Please Login or Register  to view this content.
    Last edited by amardeep20; 03-15-2013 at 01:50 AM. Reason: Included some details

  9. #9
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: VBA Tracked Changes HELP

    Somehow a 'Next' went missing before 'For Each HdFt In Sctn.Footers'. Fix that and the code should work just fine.

    Cross-posted at: http://www.vbaexpress.com/forum/showthread.php?t=45648
    For cross-posting etiquette, please read FORUM RULE 8: http://www.excelforum.com/forum-rule...rum-rules.html

  10. #10
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA Tracked Changes HELP


  11. #11
    Registered User
    Join Date
    02-01-2013
    Location
    mumbai
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: VBA Tracked Changes HELP

    Hi Paul,

    I am new to these forums and shall be careful in future. Thanks for letting me know.

    Thanks once again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1