Closed huiettcm closed 1 year ago
Hi @huiettcm ,
Your problem is that you are using Application.InputBox
which is different from VBA.InputBox
.
I've just added an InputBox
(same as VBA.InputBox
) to the Demo file. There is a button with the same name once the demo is run. This one works just fine.
Since you are using Application.InputBox
with Type:=2
which is String
anyway, you can basically replace the line:
ui = Application.InputBox("Enter Threshold/Objective Units for " & ctrl.value, Type:=2)
with:
ui = InputBox("Enter Threshold/Objective Units for " & ctrl.value)
and your problem is solved. Also, there is no need to call DisableMouseScroll Me
before or EnableMouseScroll Me
after.
However, if you are planning to use the Application.InputBox
with other types or even if you really need to use it anyway then the problem is that Application.InputBox
makes the userform modeless.
As per the Notes section, this repository does not work with modeless forms. The code I wrote specifically disconnects the mouse hook to prevent a crash when the form is not modal. Even after the Application.InputBox
is closed, the form is still modeless and you can test by being able to click cells in worksheets.
So, when using Application.InputBox
, the form must be made modal back again. This can be achieved by hiding and then re-showing the form with .Show vbModal
or just .Show
if the form's ShowModal
property is set to True
.
I didn't knw that '''vba.inputbox''' (or more simply '''inputbox'''...) was an option and different than applicaiton.
. It's much easier to just use the other input rather than reshow the form. Seems like an extra processing step that's really unnecessary. I also deleted the disable/enable lines. that was an misguided attempt to get around the wrong input boxes.
Thank you so much!
Good afternoon! My user form has a couple of instances where I use Application.InputBox to update some of the comboboxes. When the input box comes up the userform looses the mouse control. I tried disablemousescroll before the input box and enable after, but I still loose the scroll.
for example, i have comboboxes to standardize units of measure. There's an 'Other' option that brings up an inputbox for user input. If this isn't enough code to recreate, I can send the file, but I feel like it'd be a lot to go through.