I have this class in C# which i developed from examples:
If you check the constructor there is the word "Workbooks" which suits when opening Excel application from C#.Code:class ManagedAccess:IDisposable { dynamic _access; dynamic _doc; bool _isDisposed = false; public ManagedAccess(string filePath = "") { _access = new Microsoft.Office.Interop.Access.Application(); _access.Visible = true; if (filePath.Equals(string.Empty)) { _doc = _access.Workbooks.Add(); _doc.Activate(); } else { _doc = _access.Workbooks.Open(filePath); } } protected virtual void Dispose(bool isDisposing) { if (this._isDisposed) return; if (isDisposing) { this._access.Quit(); } // Release unmanaged resources here //if (this._excel != null) //{ // System.Runtime.InteropServices.Marshal.ReleaseComObject(this._excel); //} // Indicate that the object has been disposed. this._isDisposed = true; } ~ManagedAccess() { this.Dispose(false); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } }
Though Access usage will decrease, we still use old Access software and lot of apps are built with it, so I might need to open an Access program from C#.
What should i replace "Workbooks" with in the following code:
This is using Microsoft office Interop libraries and the IDisposable pattern in C#Code:if (filePath.Equals(string.Empty)) { _doc = _access.Workbooks.Add(); _doc.Activate(); } else { _doc = _access.Workbooks.Open(filePath); }




Reply With Quote
