Word - save a document from a task pane

Add-in Express™ Support Service
That's what is more important than anything else

Word - save a document from a task pane
 
Ben Smith




Posts: 1
Joined: 2013-02-13
Hi

We have created a task pane that opens when certain HTML documents are opened in word (as part of a line of business application). Some data is typed into fields in the task pane which are saved to a specific XML document (separate from Word) but relates to this document.

1. We have a save button on the task pane, how do we save & close the current document using this button? we are struggling with this.

In addition we would like to (only when the task pane is open on the active document):

2. Catch the document close event to save the XML data
3. Catch the save event and save as filtered HTML instead of normal HTML

Thanks
Posted 18 Feb, 2013 06:40:34 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Ben,

#1. Please see Word.Application.ActiveDocument, Word.Document.Save() and Word.Document.Close().

#2. This is the most tricky part. For first, I have an impression that the BeforeDocumentClose event is named incorrectly. I would add ALL event handlers to the ADXWordAppEvents component - see Add Events... in the context menu of the add-in module's designer surface - and test what events occur in this or that scenario in all supported Word versions. This would be the first-hand info on the order of events.

Alternatively, consider storing that info in the Document.CustomDocumentProperties collection which holds objects of the Office.Document type. Or, you can probably use the Document.Variables collection.

#3. I would use a number of ADXRibbonCommand components (I assume we talk about Word 2007-2013) to intercept invoking the corresponding Ribbon controls. In the OnAction event of the ADXRibbonCommand you can show the Save dialog, check what the user's choice and perform the required action except for the Save As Html case. Please check this blog:

http://www.add-in-express.com/creating-addins-blog/2012/02/16/word-dialogues-programmatically/


Andrei Smolin
Add-in Express Team Leader
Posted 18 Feb, 2013 08:31:14 Top