As I have been explained (kudos go respectively), this is a COM feature.
By default COM assumes an interface is extensible, that is, it allows adding members at run time. If that is not the desired behaviour, one can apply the [nonextensible]
attribute to the interface definition, which declares the interface only accepts methods explicitly defined in the type library.
dispinterface _Application
and dispinterface _Workbook
do not have this flag set in the Excel type library, dispinterface _Worksheet
does.
Similarly, ADO's dispinterface _Connection
does not have [nonextensible]
, dispinterface _Command
does.
To learn which are extensible, add a reference to TypeLib Info
in the project's References and run:
Dim t As tli.TLIApplication
Set t = New tli.TLIApplication
Dim ti As tli.TypeLibInfo
Set ti = t.TypeLibInfoFromFile("excel.exe")
Dim i As tli.InterfaceInfo
For Each i In ti.Interfaces
If (i.AttributeMask And tli.TYPEFLAG_FNONEXTENSIBLE) <> tli.TYPEFLAG_FNONEXTENSIBLE Then
Debug.Print i.Name
End If
Next
You will see that almost all interfaces are extensible here, so most of them get pushed out of the debug window and you will only see the last ones. Change the <>
to =
to print those that are not extensible, there are much less of them.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…