I'm using IronPython (Python for C#) to access Excel via COM, but it looks like the COM interface is what's giving me trouble, so this should also apply to VBA. I notice that Application.Workbooks.Count only works sometimes. If I have a handle on Excel, I can usually go through the workbooks without any problems. However, if I double click on a cell in excel to enter the edit mode, I cannot access Workbooks.Count property. Listing all COM object properties on Workbooks, it looks like it just becomes an primitive object with no real properties. Here are all the properties of Workbooks collection when excel is not in an in-cell edit mode:
['Add', 'Application', 'CanCheckOut', 'CheckOut', 'Close', 'Count', 'CreateObjRef', 'Creator', 'Equals', 'Finalize', 'GetEnumerator', 'GetHashCode', 'GetLifetimeService', 'GetType', 'InitializeLifetimeService', 'Item', 'MakeDynamicType', 'MemberwiseClone', 'Open', 'OpenDatabase', 'OpenText', 'OpenXML', 'Parent', 'Reduce', 'ReferenceEquals', 'ToString', '_Open', '_OpenText', '_OpenXML', '__OpenText', '__class__', '__doc__', '__getitem__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__']
and here are all the properties when excel is in in-cell edit mode:
['CreateObjRef', 'Equals', 'Finalize', 'GetHashCode', 'GetLifetimeService', 'GetType', 'InitializeLifetimeService', 'MakeDynamicType', 'MemberwiseClone', 'Reduce', 'ReferenceEquals', 'ToString', '__class__', '__doc__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__']
Is there a different way to access workbooks? Or maybe there's a property on the Application object that could tell me if workbooks are accessible? Any help is appreciated, thanks!
Bookmarks