Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel addin from C# - Trap excel events | Excel Programming | |||
How do you fire HTML events using Excel to automate IE? | Excel Programming | |||
Which Events Fire When I Delete A Row, and How Many Times? | Excel Programming | |||
On open/closed events-and stuff | Excel Programming | |||
Temporary storage, Addin events | Excel Programming |