I tried to add one VBA project Lib
as reference for a second VBA project App
and the default class members don't work.
Is this a limitation of VBA? Or is there something I need to do to get it to work?
Here are some more details:
- In
Lib
I have defined the classMyClass
with the default memberDefaultMember
(defined by addingAttribute MyClass.VB_UserMemId = 0
with a text editor to the module). - I added
Lib
as a reference to theApp
- I can
Dim X As MyClass
in bothLib
andApp
. - In
Lib
these are equivalent:X.DefaultMethod(123)
andX(123)
. - In
App
this works:X.DefaultMethod(123)
, but this doesn't:X(123)
.
EDIT
Turns out I had a conflict with class names and everything works as expected: some of the names of my classes with default members were also used in other referenced libraries. Perhaps after adding the new Lib
as a reference, the default MyClass
all of a sudden changed and became the one defined in another library that doesn't have the default member.