+ Reply to Thread
Results 1 to 3 of 3

Outlook VBA set focus on Opened Workbook

  1. #1
    Registered User
    Join Date
    06-22-2020
    Location
    Alaska
    MS-Off Ver
    2016
    Posts
    4

    Outlook VBA set focus on Opened Workbook

    Cross-posted at https://www.mrexcel.com/board/thread...kbook.1198253/ --6SJ

    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.
    Last edited by 6StringJazzer; 03-08-2022 at 05:05 PM. Reason: cross

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Outlook VBA set focus on Opened Workbook

    If I were doing this I would write all the macros in Outlook rather than calling a macro in an Excel file.

    But as it is, you should be able to do this. But you'll need to show us your Outlook code. Please paste the code into a post, and use code tags.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    06-22-2020
    Location
    Alaska
    MS-Off Ver
    2016
    Posts
    4

    Re: Outlook VBA set focus on Opened Workbook

    I was having a tough time getting my code to work when I had all of it living in Outlook.

    Here's the Outlook code to take apart the subject line and body and then summon Excel.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Form loses focus after using Outlook folder picker
    By Tooley in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2017, 01:39 PM
  2. Switch focus back to Excel from Outlook
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-14-2015, 06:45 AM
  3. Use a macro to extract cell data from opened workbook to new opened workbook
    By BrianTFC in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-26-2014, 01:35 PM
  4. Reply opened Outlook message
    By Safadinhu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2013, 03:56 PM
  5. Workbook focus when opened by another workbook
    By wrobs in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-24-2010, 02:08 PM
  6. Email macro to toggle focus between excel and outlook
    By kuraitori in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2009, 12:30 AM
  7. [SOLVED] Why is Excel being opened in Outlook?
    By JW in forum Excel General
    Replies: 1
    Last Post: 05-04-2005, 12:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1