Grab window handle with any click on a userform

bmlkkidd

New Member
Joined
May 9, 2022
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
Good morning all,

I'm using the typical method of using a window handle to re-activate an instance that launched a userform. However, I need to run the FindWindow routine from every control in order for it to work. I have well over 200 controls in the multi-page userform, and it will be extremely tedious to do this.

How else can I accomplish this? Here's the full scenario:

We have a quoting tool that launches a user form. The sales team will frequently call up or already have up other Excel workbooks. When they go back to the user form, if they did not click into the calling instance first, then the controls and control sources are looking at what Excel believes is the Active Workbook. So I need any click on the userform (whether a radio button, text field, combobox, etc.) to grab the quoting tool instance. I've used the window handle before as well as Workbooks("Quoting Tool").Activate in cases before, but I had to include a pointer to a module in each control's events.

What is the easiest way to accomplish this? Do I need a class module to monitor each type of control? Simply adding the the userform Activate or MouseMove/MouseDown events don't work for the individual controls.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Why don't you just use ThisWorkbook in the relevant userform code rather than ActiveWorkbook?
 
Upvote 0
I can use either method, but what I am after is a way to run the code to set the active workbook regardless of where they click in the Userform, whether it be a textbox, combobox, radio button, the form itself, etc.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top