Zars01
05-30-2017, 06:28 PM
Hi! Here's the tldr; - my topmost UserForm loses focus after an Application.InputBox grabs user input.
I have a macro that pulls open a lot of UserForms. They're all ShowModal = True.
The UserForm with the (mild) issue is called from UserForm 2 or 3, depending on user interaction.
It adds labels depending on the underlying Excel sheet and uses a class to give each label properties, DblClick, MouseDown, MouseMove, MouseUp events, etc.
Everything works fine and I'm very happy with it - except ...
The DblClick event calls "Application.InputBox" - after, the user must click the UserForm to reapply focus ...
As far as code, after Application.InputBox is called -
User input is verified, stored, and used to change the label's Left.
A function is called that reads EVERY label's left, and updates a few key control tags and colors, etc.
This is a very small issue as it doesn't really interfere with functionality.
At worst, it just feels like the computer is being slow, etc. when you have to double click to press a button (once to activate the UserForm, once to call the event).
Still, it's a puzzle ...
Here's what I've tried so far:
Attempts that didn't compile:
Setting focus on the label (because labels don't take focus)
UserForm.Show (already shown, Modal)
Setting focus on a command button on the UserForm (this APPEARS to work, the UserForm's gray title bar becomes blue - but user must still click on UserForm to interact with it)
Using AppActivate to activate Excel (no impact)
I have stepped through, of course. No insight gained.
I'm using Microsoft Excel 2013.
Any ideas?
I have a macro that pulls open a lot of UserForms. They're all ShowModal = True.
The UserForm with the (mild) issue is called from UserForm 2 or 3, depending on user interaction.
It adds labels depending on the underlying Excel sheet and uses a class to give each label properties, DblClick, MouseDown, MouseMove, MouseUp events, etc.
Everything works fine and I'm very happy with it - except ...
The DblClick event calls "Application.InputBox" - after, the user must click the UserForm to reapply focus ...
As far as code, after Application.InputBox is called -
User input is verified, stored, and used to change the label's Left.
A function is called that reads EVERY label's left, and updates a few key control tags and colors, etc.
This is a very small issue as it doesn't really interfere with functionality.
At worst, it just feels like the computer is being slow, etc. when you have to double click to press a button (once to activate the UserForm, once to call the event).
Still, it's a puzzle ...
Here's what I've tried so far:
Attempts that didn't compile:
Setting focus on the label (because labels don't take focus)
UserForm.Show (already shown, Modal)
Setting focus on a command button on the UserForm (this APPEARS to work, the UserForm's gray title bar becomes blue - but user must still click on UserForm to interact with it)
Using AppActivate to activate Excel (no impact)
I have stepped through, of course. No insight gained.
I'm using Microsoft Excel 2013.
Any ideas?