Execute VBA upon focus return to Excel

LGFN1

Board Regular
Joined
Jun 25, 2014
Messages
63
I have a VBA code that changes the focus to another OS window. Is it possible to tell VBA to run a different code when the focus returns to Excel? I don't want VBA to force the focus back, it should wait patiently, but as soon as I give it back the focus, a different code should execute.

Thank you.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You should Post ( Paste ) your code if not possible

look at the Shell command in help

Also be aware that is asynchronous and after the call will start running the code that follows

So use a loop




</SPAN></SPAN>
 
Upvote 0
The code is as simple as:
Code:
Workbooks.Open FileName:="C:\Users\User\Documents\[...].xlsm"
 
Upvote 0
Maybe more of an explanation of what it is you are trying to do rather request for code might help us understand better



is there an AutoOpen style macro in the XLSM that you're opening?


if it is as simple as opening a workbook then the statements following will be executed one the open work book operation has finished

Workbooks.Open FileName:="C:\Users\User\Documents\[...].xlsm"
Msgbox " now continue "
...</PRE>
 
Upvote 0
I tried with a test Msgbox after the open command as suggested, but as soon as the other workbook opens, the dialog appears and doesn't allow any interactions with the workbook itself.
 
Upvote 0
The dialog is System Modal which means for the EXCEL PROGRAM that dialog has to be dealt with first, before anything else can happen, try setting the ShowModal property to false on the Dialog user form
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,268
Members
448,558
Latest member
aivin

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