I have a userform where the objects are added programmatically. Can I also add mouseover/click events to the objects? The number of objects is determined at run time so unable to add code at design time.
I have a userform where the objects are added programmatically. Can I also add mouseover/click events to the objects? The number of objects is determined at run time so unable to add code at design time.
Please click *Add Reputation if I've helped
Perhaps this will help.
Extensibility: Programming The VBA Editor
Surround your VBA code with CODE tags e.g.;
[CODE]your VBA code here[/CODE]
The # button in the forum editor will apply CODE tags around your selected text.
Hi,
If the code is the same for groups/types of control you can use classes to handle the events. If it isn't, you would have to add the code through the Designer while the form is closed.
Don
Please remember to mark your thread 'Solved' when appropriate.
Thanks so much for your responses.
The userform is designed to be run on colleagues machines and while I can reference a library, I'd rather not have to get them to trust access to the VBProject.
Effectively, when the mouse is over a help icon for a textbox (just a label with the caption "(?)"), I want the caption of another label on the form to populate with help text for that textbox. The help text itself I can store in the tag property for the help icon.
So, each help icon will have a different name obvs, but the code just needs to get the tag for that help icon and display it, so object name aside the code will be the same. My naming conventions mean that the name for each of these help icons start with the letters "hlp" and will be the only objects on the userform that do so. As I write this, your plan sounds very possible. Could you help me further?
Can you provide a sample workbook to save me creating one from scratch? If not, I will attempt to provide some sample code tomorrow.
Thanks man. Sample attached. This is part of a much larger project but everything you need should be here. The purpose of the userform is to allow a user to edit "settings" that would be used in the rest of the code.
Last edited by kadeo; 09-20-2016 at 04:25 AM.
Thank you. Which label(s) should contain the help text?
In the DisplaySettings procedure of the UserForm, the third block that creates objects where the caption is set as " (?) " and the name of the label is appended to " hlp ". This bit:On the UserForm itself, it's the column of " (?) " to the right hand side.Please Login or Register to view this content.
Last edited by kadeo; 09-20-2016 at 05:24 AM.
Oh wait, I just realised you probably meant which label will display the help text. Haven't got around to creating that yet, but I was gonna place it in the space between the "buttons" at the top and the frame.
That doesn't allow very much room to display the text. Are you expecting the form to resize?
I'm just adding the functionality at the moment, I'm gonna worry about aesthetics later.
I had not in fact seen your last post- I was referring to the help labels themselves.
Herewith a simplistic example of a class-based approach. Clicking each label will update the help text in the newly added textbox.
Last edited by xlnitwit; 09-20-2016 at 05:50 AM.
Like you said, it's so simple. You didn't add much code at all. This is doing exactly what I need now, thanks so much for your help.
Man, I wish I could get to grips with classes, they've eluded me for so long.
You're welcome.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks