cristianbuse / VBA-UserForm-MouseScroll

Use the Mouse Scroll Wheel to scroll VBA UserForms and Controls
MIT License
70 stars 12 forks source link

MouseOverControl variable not defined #25

Closed huiettcm closed 1 year ago

huiettcm commented 1 year ago

I've added your code to a userform with lots of textboxes and comboboxes. Those are the only two controls on the userform other than labels. I am using Office 365 and the associated desktop app. I believe the Windows Common Controller reference has not been adapted for this version of excel. However, your demo file works great. I've added the class module and the regular code module no issues. When I start my form, I get a 'Variable not defined' compile error (image attached). The error is on the line subControls.Add MouseOverControl.CreateFormControl(frmCgtrl, hWndForm) And the MouseOverControl is highlighted. IDK why there's no instantiation of the class at that point in the AddForm sub....thoughts?

cristianbuse commented 1 year ago

Hi @huiettcm ,

Don't copy paste the code. Clone the repository or download the zip file and then import the modules.

VB* modules have hidden attributes that you can only see in a text editor. For example the top 9 lines in the class module are clearly visible as text but when you import the module, you won't see them in the IDE. This is unfortunately one of the many issues with the VBA editor. So, copy-paste does not work in this case because you need the special Attribute VB_PredeclaredId = True but when copy-pasting it gets defaulted to False.

huiettcm commented 1 year ago

PERFECT!!!! Thank you! Now I understand what I'm seeing in the text editor.