exit from current word window

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

exit from current word window
 
zipi sompo




Posts: 125
Joined: 2013-09-03
Hi,
I have a custom task pane in word.
in my pane I want after save a file to exit from the word window.
I try:

AddinModule.CurrentInstance.WordApp.Quit(oMissing, oMissing, oMissing);


but if I have another word file that open ,it also close..
how can i close only the docs that i work on it from my pane?

Thanks!
Posted 25 Mar, 2015 02:17:10 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Zipi,

A document may be displayed in several windows: On the View tab, click New Window (in the Window group). so, the question is: what do you want to close: the window or the document?

If window, see https://msdn.microsoft.com/en-us/library/office/ff845707.aspx.
If document, see https://msdn.microsoft.com/en-us/library/office/ff196343.aspx.

WordApp.Quit closes Word itself.


Andrei Smolin
Add-in Express Team Leader
Posted 25 Mar, 2015 04:47:04 Top
zipi sompo




Posts: 125
Joined: 2013-09-03
I have several word docs open.
I want click on button in the pane and the word doc that I click in his button will close.

I try:

 AddinModule.CurrentInstance.WordApp.ActiveWindow.Close(ref oMissing, ref oMissing);
((_Document)AddinModule.CurrentInstance.WordApp.ActiveDocument).Close(ref oMissing, ref oMissing, ref oMissing);

but in both.
the doc is close but still the window open with empty window. I want to close it.
Thanks!
Posted 26 Mar, 2015 02:28:25 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Zipi,

I think you run into this after you close the last window. If so, you can check Windows.Count and call WordApp.Quit().


Andrei Smolin
Add-in Express Team Leader
Posted 26 Mar, 2015 02:45:53 Top