ThisDocument_BeforeSave fails to use e.Cancel RRS feed

  • Question

  • Hi all,
    I have a truly embarrassing issue with  ThisDocument_BeforeSave. The event gets fired and I set
    e.Cancel = true but the document gets saved anyway.
    This issue appeared quite recently in the code that has been around for almost three years. I wonder if anyone has seen that happening or has any clues.
    I am using VSTO 3.0 with Office 2007
    Thank you.
    Tuesday, March 26, 2013 3:02 PM


All replies

  • One more detail. Setting e.ShowSaveAsDialog to true also has no effect - save as dialog is not popping up. It almost looks like I am operating on a local copy of SaveEventArgs.
    Tuesday, March 26, 2013 3:07 PM
  • Bingo! I hope it saves someone else.

    I noticed that some of the assemblies are loaded with 10.0 version:
    'WINWORD.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Tools.Office.AddInAdapter.v10.0....
    'WINWORD.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Tools.Applications.AddInAdapter.v10.0...
    'WINWORD.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Tools.Applications.Contract.v10.0...

    I unninstalled VS Tools for office runtime for Office 2010. Once I did it, the assemblies above were loaded from version 9.0 images. The bug went away.

    So here are my question to MS developers.
    1. Why version 9.0 of VSTO is trying to load some assemblies from 2010 tool kit? Shouldn't it be version specific?
    2. Can you please confirm that there is no backward compatibility for BeforeSave event?

    Thank you.


    Tuesday, March 26, 2013 4:36 PM
  • Hi Alex,

    Thank you for posting in the MSDN Forum.

    For the most part, the rule is that the last version that was installed is the version that loads with Automation.

    Best regards,

    The above paragraph was picked from Office automation when multiple versions of Office are installed.

    I think this might be the cause of your issue, since I've noticed that you've installed both Office 2007 and Office 2010.

    Hope it helps.

    Best regards,

    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 28, 2013 1:30 PM