none
Intercep FileOpen in Office RRS feed

  • Question

  • Hello,

    Could you advise me how I can intercept the File Open & File Save as in ms Office?

    Thanks.

    • Moved by Cindy Meister MVPModerator Monday, November 26, 2012 4:42 PM not using VSTO technology (From:Visual Studio Tools for Office)
    Sunday, November 25, 2012 9:17 AM

Answers

  • I'm not sure what you want to do is even feasible. It's not possible to "interop" with an Office application without its automation COM DLLS. (Note that I'm talking about the Office APIs, not the PIAs .NET requires - your terminology is not clear on this point.)

    <<...since client machine may not contain Office... >>

    If a client machine does not have Office installed, then you cannot use Office functionality. Period. There are no ifs, ands, buts or workarounds.

    Also, this question does not pertain in any way to the VSTO technology, since you don't want to install in-process DLLs. Therefore I'm going to move it to the General Office Development forum.


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, November 26, 2012 9:05 AM
    Moderator

All replies

  • Which version(s) of Office?

    What kind of solution are you working on?


    Cindy Meister, VSTO/Word MVP, my blog

    Sunday, November 25, 2012 2:38 PM
    Moderator
  • Office 2007 & 2010. I have no idea what is the possible solution. I am researching. I am looking to the Interop COM events of Office. I  maybe looking to Reflection. I see macros can do that, but I have no idea with .NET.
    Sunday, November 25, 2012 2:42 PM
  • In Word 2007 and Word 2010 there are two basic approaches and both available to .NET:

    1) Re-purpose the commands in Ribbon XML

    2) Track the DocumentOpen and DocumentBeforeSave events

    (1) requires your code to be running in-process, as would be the case with a VSTO solution.

    (2) can be done with VSTO as well as with an out-of-process solution (such as a Windows Form). Note also with (2) that the event is DocumentBeforeSave meaning you can't be absolutely certain the document was saved - there is no matching DocumentAfterSave event.


    Cindy Meister, VSTO/Word MVP, my blog

    Sunday, November 25, 2012 2:51 PM
    Moderator
  • With (1), This looks good but it requires to install add-on DLL that may not preferred.

    (2), the DocumentOpen is too late, right? I want to catch when user clicks File->Open. Not after the Document is opened.

    Note: With my project, I must not add reference of Office Interop DLLs since client machine may not contain Office and must not require to install Primary Interop Assembly. What I have to do is all at run-time, not design time.

    Sunday, November 25, 2012 4:58 PM
  • I'm not sure what you want to do is even feasible. It's not possible to "interop" with an Office application without its automation COM DLLS. (Note that I'm talking about the Office APIs, not the PIAs .NET requires - your terminology is not clear on this point.)

    <<...since client machine may not contain Office... >>

    If a client machine does not have Office installed, then you cannot use Office functionality. Period. There are no ifs, ands, buts or workarounds.

    Also, this question does not pertain in any way to the VSTO technology, since you don't want to install in-process DLLs. Therefore I'm going to move it to the General Office Development forum.


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, November 26, 2012 9:05 AM
    Moderator
  • Thanks. I am trying API Hook for this. It must be a good approach for my purpose.
    Monday, November 26, 2012 9:08 AM
  • I'm not sure we're on the same wavelength with "API Hook" - new term for me. In any case...

    << File Open & File Save as >>

    Besides what I mentioned, the only possibility that occurs to me is the Ribbon Accessibility APIs:

     http://msdn.microsoft.com/en-us/library/bb404170.aspx


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, November 26, 2012 4:41 PM
    Moderator