Hi
Based on my test that host a word document in IE or in the DSOFramer
control, the OnBeginShutdown ,OnDisconnection ... method will be called if
we directly close the host application.
Here is the dbgview log.
00000000 0.00000000 [3864] OnConnection
00000001 0.00126232 [3864] OnAddInsUpdate
00000002 0.00877375 [3864] Microsoft Word On Connection
00000003 0.00883164 [3864] ConnectMode = 1
00000004 0.00888128 [3864] Custom(1) = 2
00000005 0.00892874 [3864] App Version = 11.0
00000006 0.00920941 [3864] gbIsValidLangSetting = True
00000007 0.01012617 [3864] gbBootLoad = True
00000008 0.01020831 [3864] OnAddInsUpdate
00000009 0.01028770 [3864] Microsoft Word On AddInsUpdate
00000010 0.08180493 [3864] Standard
00000011 0.10025600 [3864] Found Control Undo
00000012 0.10662775 [3864] Found Control Redo
00000013 0.10771541 [3864] Microsoft Word On StartupComplete
00000014 9.48894708 [3864] OnBeginShutdown
00000015 9.48907862 [3864] Microsoft Word On BeginShutdown
00000016 9.48948961 [3864] OnDisconnection
00000017 9.48962602 [3864] Microsoft Word On Disconnection
00000018 9.48967768 [3864] RemoveMode = 0
00000019 9.57271826 [3864] DLL_PROCESS_DETACH in MSGR3SC.DLL
Here is my test addin.
namespace MyWordAddin1
{
using System;
using Microsoft.Office.Core;
using Extensibility;
using System.Runtime.InteropServices;
using Word = Microsoft.Office.Interop.Word;
using System.Diagnostics;
[GuidAttribute("10F9EBA7-4332-4BA2-9C79-59AC13621BD6"),
ProgId("MyWordAddin1.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
public Connect()
{
}
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
Debug.WriteLine("OnConnection");
wdApp = application as Word.Application;
}
public void OnDisconnection(Extensibility.ext_DisconnectMode
disconnectMode, ref System.Array custom)
{
Debug.WriteLine("OnDisconnection");
}
public void OnAddInsUpdate(ref System.Array custom)
{
Debug.WriteLine("OnAddInsUpdate");
}
public void OnStartupComplete(ref System.Array custom)
{
Debug.WriteLine(wdApp.CommandBars[1].Name);
foreach(CommandBarControl cbc in wdApp.CommandBars[1].Controls)
{
if(cbc.Id == 128)
{
Debug.WriteLine("Found Control Undo");
cbcbUndo = cbc as CommandBarComboBox;
if (cbcbUndo!=null)
cbcbUndo.Change+=new
_CommandBarComboBoxEvents_ChangeEventHandler(cbcb_Change);
else
Debug.WriteLine("cbcbUndo is NULL");
}
if(cbc.Id == 129)
{
Debug.WriteLine("Found Control Redo");
cbcbRedo = cbc as CommandBarComboBox;
if (cbcbRedo!=null)
cbcbRedo.Change+=new
_CommandBarComboBoxEvents_ChangeEventHandler(cbcb_Change);
else
Debug.WriteLine("cbcbRedo is NULL");
}
}
}
public void OnBeginShutdown(ref System.Array custom)
{
Debug.WriteLine("OnBeginShutdown");
}
private Word.Application wdApp=null;
private CommandBarComboBox cbcbUndo=null;
private CommandBarComboBox cbcbRedo=null;
private void cbcb_Change(CommandBarComboBox Ctrl)
{
Debug.WriteLine("cbcb_Change");
}
}
}
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.