T
Toxter
Hello everyone,
I'm developing Word 2003 addin.
My addin adds some new menu items to Word menu bar.
Something like this:
Microsoft.Office.Core.CommandBarControl cc;
public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
applicationObject = application;
addInInstance = addInInst;
try
{
Microsoft.Office.Interop.Word.Application wApp =
(Microsoft.Office.Interop.Word.Application)application;
((Microsoft.Office.Interop.Word.ApplicationEvents4_Event)wApp).Quit += new
Microsoft.Office.Interop.Word.ApplicationEvents4_QuitEventHandler(Connect_Quit);
object missing = Type.Missing;
cc =
wApp.CommandBars.ActiveMenuBar.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlPopup,
missing, missing, missing, false);
cc.Caption = "Call BT";
}
catch (Exception ex){}
}
void Connect_Quit()
{
try
{
Microsoft.Office.Interop.Word.Application wApp =
(Microsoft.Office.Interop.Word.Application)applicationObject;
cc.Delete(Type.Missing);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
What I'm trying to do is to cleanup on Word.Quit all of my added menu items
and toolbars.
But I'm geting an exception:
Exception from HRESULT: 0x800A01A8
So my desirable scenario is:
1. Start Word;
2. Add my toolbars
3. User is working in Word;
4. Begin of Shutdown of Word;
5. Delete my toolbars;
6. Word is closed.
How can I remove all of my added controls on Word shutdown?
Thanks.
I'm developing Word 2003 addin.
My addin adds some new menu items to Word menu bar.
Something like this:
Microsoft.Office.Core.CommandBarControl cc;
public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
applicationObject = application;
addInInstance = addInInst;
try
{
Microsoft.Office.Interop.Word.Application wApp =
(Microsoft.Office.Interop.Word.Application)application;
((Microsoft.Office.Interop.Word.ApplicationEvents4_Event)wApp).Quit += new
Microsoft.Office.Interop.Word.ApplicationEvents4_QuitEventHandler(Connect_Quit);
object missing = Type.Missing;
cc =
wApp.CommandBars.ActiveMenuBar.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlPopup,
missing, missing, missing, false);
cc.Caption = "Call BT";
}
catch (Exception ex){}
}
void Connect_Quit()
{
try
{
Microsoft.Office.Interop.Word.Application wApp =
(Microsoft.Office.Interop.Word.Application)applicationObject;
cc.Delete(Type.Missing);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
What I'm trying to do is to cleanup on Word.Quit all of my added menu items
and toolbars.
But I'm geting an exception:
Exception from HRESULT: 0x800A01A8
So my desirable scenario is:
1. Start Word;
2. Add my toolbars
3. User is working in Word;
4. Begin of Shutdown of Word;
5. Delete my toolbars;
6. Word is closed.
How can I remove all of my added controls on Word shutdown?
Thanks.