Outlook VBA set focus on Excel workbook

Jakson

New Member
Joined
Sep 14, 2021
Messages
21
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I've got a pair of macros that interact with Outlook and Excel. The process starts when a new email comes into my inbox. The first Outlook macro kicks on and opens a specific Excel document. It then takes apart the email body and subject and passes those strings as vars to the Excel doc. Once the Outlook macro finishes passing Excel takes over and does a find command to find a match of a string var on the doc. Once it's found, it places the strings in related cells.

The issue I'm running into is activating Excel in a way that sets focus on it so that Excel's VBA can actually execute. Under my current circumstances the following behavior is observed:

Email comes in. Outlook VBA takes over and splits apart the strings. Outlook VBA then calls the Excel VBA macro to take over - at this point execution stops until the user manually sets focus on Excel. Then the Excel macro starts execution with a msgbox stating that it is now firing.

I need to dodge this having to manually set focus on Excel. These macros are intended to operate in complete autonomy except when things go catastrophically wrong. (There's a few debug routines built in to stop the greater operations and alert a human that things are wrong.)

I've poked around and become aware of a few methods but none of which I've been able to digest to a point of capitalizing on them.

TL;DR: I need Outlook to set focus an Excel doc which it opened via a string path so that the Excel doc can execute macro functions autonomously.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Outlook VBA set focus on Opened Workbook
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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