English 中文(简体)
Access Document Stream from Office Ribbon Code
原标题:

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

问题回答

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.

Another approach might be to get the XML representation of the open document, using .WordOpenXML

That will be the current state (ie including unsaved changes).





相关问题
Building a Com addin for Office 2000 / Office 2007

I am struggling to find a straight forward guide to creating office addins using VSTO and VB.net. Specifically I would like to know how to be able to create a addin/ dll which can either be ...

VSTO 3.0 Excel 2007 Addin Tab doesn t display

This is a very odd problem I ve found. I have written and successsfully deployed a VSTO 3.0 Addin for Excel 2007. The problem is that the Tab for the Ribbon only shows up on NEW instances of Excel; ...

VSTO - Outlook 2007 - Display form before send message?

I m new to Outlook add-in programming and not sure if this is possible: I want to display a pop-up form (or selection) and ask for user input at the time they click Send. Basically, whenever they ...

deleting named ranges in VSTO

I have a VSTO spreadsheet, and have re-jigged the front end. I need to change some named ranges to reflect this. Couldn t see a good way of doing this, so I created other named ranges and pointed ...

VSTO remove file without resigning the manifest

I have a file added to my vsto project and I want to remove this file after publishing the project. This is because the file should only be avaliable for some customers, for others we want to remove ...

Is there a future for PowerPoint VBA/VSTO? [closed]

Does anyone know what the future holds for VBA/VSTO programming in PowerPoint? I ve been working on a Office automation project and find it frustrating to work with PowerPoint in particular since it ...

热门标签