LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Workbook not closed when OnBeginShutdown and OnDisconnection events fire in Excel Addin

I have built a Shared Add-in project using Visual Studio 2003, VB.NET and
Framework 1.1.
It is designed to run in Excel. I modifed the wizard generated code to use
the Excel COM object model.
I added a COM reference to the Excel 11.0 object library. I then declared a
class instance-level variable of type Excel.Application, WithEvents. I then
printed out the Workbooks.Count in the OnBeginShutdown and OnDisconnection
events; and they both show a count of 1.

My goal is to check in the Excel file to a document management system when
the workbook closes, but the file is still in use and the DMS can't move it
from the local system.

Here is my code:

Imports Microsoft.Office.Core
Imports Extensibility
Imports System.Runtime.InteropServices
Imports MOI = Microsoft.Office.Interop

<GuidAttribute("61BEC854-3387-4B79-B9C4-BBE7AB328D5A"),
ProgIdAttribute("TestExcelAddin.Connect") _
Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim WithEvents applicationObject As MOI.Excel.Application
Dim addInInstance As Object

Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown
System.Diagnostics.Debug.WriteLine("OnBeginShutdow n: WorkBooks.Count
= " & applicationObject.Workbooks.Count)
End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
End Sub

Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnDisconnection
System.Diagnostics.Debug.WriteLine("OnDisconnectio n: WorkBooks.Count
= " & applicationObject.Workbooks.Count)
End Sub

Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As
System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
applicationObject = application
addInInstance = addInInst
End Sub
End Class


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel addin from C# - Trap excel events Karthikeyan N Excel Programming 1 May 4th 05 09:47 PM
How do you fire HTML events using Excel to automate IE? Jason Excel Programming 2 March 1st 05 12:09 AM
Which Events Fire When I Delete A Row, and How Many Times? Alan Excel Programming 2 September 21st 04 10:50 PM
On open/closed events-and stuff Wandering Mage Excel Programming 3 June 9th 04 02:20 PM
Temporary storage, Addin events Phil Bewig Excel Programming 4 February 14th 04 08:45 PM


All times are GMT +1. The time now is 02:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"