views:

462

answers:

1

I've created my own ribbon toolbar tab with a few buttons. I can add text and similar actions to the document I'm working on. Now I want to add a button that will save the document I'm working on without using the Word save button because I want to set some of the parameters.

Every example I found showed how to save a document that was started by my code (Dim MyDoc As New Word.Application) but when I use such syntax from the ribbon button - ActiveDocument is saying that there is no active document.

Any ideas?

ThisAddIn.vb contains: Protected Overrides Function CreateRibbonExtensibilityObject() As _ Microsoft.Office.Core.IRibbonExtensibility Return New MyRibbon() End Function

MyRibbon.xml is very basic (taken from an MS sample)

Now all I'm missing is the code... ;-)

A: 

The new document that you have created is not going to be of type Word.Application. Your ribbon/add-in is running in a current Word.Application context.

If this is indeed what you are doing, you should be creating instances of Word.Document, and saving those.

What exactly is the code you are using to create the document, the ribbon, and save your changes?

casperOne