I've succesfully created an UserForm, that implements an Interface which enables showing a warning tooltip (https://youtu.be/8dvWjXgVpxk). It is working just fine when all user forms, modules and classes are located in one common project, but now I'd like to take the Interface and store it in another project, which I could then reuse in many different projects by creating reference to it (Tools -> References). Unfortunately, when I transfer the Interface and an UserForm that this Interface uses as a member variable, I'm getting an Compile error: "Private object modules cannot be used in public object modules as parameters or return types for public procedures, as public data members, or as fields of public user defined types." error message
I'm struggling with this few days now, and cannot find a propper approach.
The simplified code structure:
Main project:
module: UFManager:
Sub CATMain()
UFThatHasTooltip.Show
End Sub
user form: UFThatHasTooltip:
Implements ICanShowTooltip
Private Sub UserForm_Click()
Debug.Print "click!"
End Sub
External project:
class/interface: ICanShowTooltip:
Public myTooltip As UFTooltip
user form: UFTooltip
'empty
I think the main issue is caused by the fact, that the userform UFTooltip is considered Private and thus cannot be used in any form by anything that works as Public. I know how to solve this issue, when instead of user form I'd like to use a class as a member variable of an interface (by changing 'Instancing' property of the class from '1 - Private' to '2 - PublicNotCreatable'), but I cannot find a property of an user form that changes its behavior to 'Public'.
PS. I know that the userform UFThatHasTooltip is missing some Properties definitions demanded by the use of an Interface, but the compiler doesn't even goes that far to care about it, so I ignored them for now.
EDIT: I've managed to export .frm file of UFTooltip, edit the attribute VB_Exposed and set its value to True. That helped with the initial issue, so I developed the code further and placed it on a repo: https://github.com/hwnd-git/VBA-Interface-Sandbox Now I'd like to know if there is a way to achieve this without the need of exporting the user form and editing its .frm file.