R – Access Document Stream from Office Ribbon Code

ms-wordoffice-2007vsto

I am attempting to write an add-in for Microsoft Word 2007. I'd like to create a Ribbon Button that when clicked, gets a FileStream for the current or active document. I would assume that is possible with the Visual Studio Tools for Office. Does anyone have any sample code that would show how to do this?

Let me know if you have any questions. Thanks

Best Answer

Try this out on the ribbon button code (for document-level add-ins):

string document = Globals.ThisDocument.Application.ActiveDocument.FullName;

Then use the standard example for FileStream.Read on MSDN

*Might need to prompt or force a save first, if unsaved changes exist.

Related Topic