none
Extracting Word document versions using 2010 C++ api

    Question

  • Hi all,

    I'm maintaining an application that uses the Word API to extract data from Word docs. One thing it does is save out previous document versions as separate files. I use the Document::GetVersions() method. 

    I recently updated to Office 2010 and this no longer works. My test data is a document, created in Word 2003 as a .doc file, that contains several versions. Using the 2003 API I can save out the separate files. Now, using the 2010 API, the call to GetVersions() returns a count of zero versions.

    Is there anything I can do to get these versions out with the new API? 

    Thanks,

    Malcolm Pollack

    Thursday, December 06, 2012 11:45 PM

Answers

  • Hi Malcolm

    In that case, my guess is that Word is using the approach I suggested in my last reply: inspecting the document content directly. Since you're using C++, doing the same shouldn't be an insurmountable problem for your program (it would be for a VBA programmer).


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, December 11, 2012 7:21 AM

All replies

  • Just to be clear: I'm calling the dispatch interface from C++, using a header file generated by Visual Studio from the Office library. The method call looks like:

    LPDISPATCH GetVersions()
    {
    LPDISPATCH result;
    InvokeHelper(0x4b, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL);
    return result;
    }

    This is supposed to return a dispatch pointer to a Versions collection. It works fine with Word 2003, but returns an empty collection with Word 2010.

    Thanks for any help you can give me,

    MP

     
    Friday, December 07, 2012 5:38 PM
  • Hi Malcolm

    The Versions feature, as used in Word 2003, was discontinued in later versions of Word.


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, December 08, 2012 7:35 AM
  • Hi Cindy,

    Thanks for your response.

    I do see that the 2010 UI is able to detect that my 2003 test document has multiple versions in the file. Is there any way I can invoke that detection functionality through the 2010 C++ API? (If so, I could then flag the document as something that needs to be reprocessed with the 2003 version in order to save out the versions.)

    Thanks,

    Malcolm Pollack

    Saturday, December 08, 2012 9:26 PM
  • Hi Malcolm

    Can you describe how that's working in the UI? That might give me an idea how to workaround it in the automation interface.

    The only thing that comes to mind at the moment is to inspect the *.doc file directly (instead of through the Word application). The binary file formats are now public:

    - Forum
    - obtaining


    Cindy Meister, VSTO/Word MVP, my blog

    Sunday, December 09, 2012 8:01 AM
  • Hi Cindy,

    When I open the doc in Word 2010, and go to File->Info, under the heading "Prepare for sharing" the app cautions me to be aware that the document has versions. So it is clearly able to detect them. an API call to get_Versions(), though, just returns a collection of zero size.

    Thanks again for your help,

    Malcolm


    Tuesday, December 11, 2012 3:41 AM
  • Hi Malcolm

    In that case, my guess is that Word is using the approach I suggested in my last reply: inspecting the document content directly. Since you're using C++, doing the same shouldn't be an insurmountable problem for your program (it would be for a VBA programmer).


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, December 11, 2012 7:21 AM