none
Iterating and accepting Revisions programmatically. RRS feed

  • Question

  • I'm making a custom add-in using visual studio 2010 for MSword2010.

    I'm implementing right now a menu that allows a user to accept revisions. The functionality will mark all revisions selected( or all revisions), mark them as green, and then accept one by one.

    The problem I'm having is when the file have too many revisions (600+), when I do a "for each" iterating the revisions the loop will go forever, won't stop.

    I'm making a list of Revisions to pass to the function, so that I can have the same function to accept all and accept selected. (Accept all will pass all revisions to the list, and accept selected will pass only the selected.)

    When I go to the revisions tab on MSWord click a revision and try to click next, it won't go to the next revision as well.

    Does anyone knows what is causing this problem?

    Thursday, January 15, 2015 2:53 PM

Answers

  • Hello Dan,

    What code do you use? Could you please be more specific?

    Anyway, I'd recommend using the for loop instead of the foreach one. It will allow to release underlying COM objects. Use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. You can read more about that in the Systematically Releasing Objects article in MSDN, it is related to Outlook, but the same principles can be applied to all Office applications.

    • Marked as answer by Dan0b10001 Friday, January 16, 2015 2:08 PM
    Thursday, January 15, 2015 5:09 PM