Select Home Tab from VBA after running custom search RRS feed

  • Question

  • I waited to switch to Outlook 2013 from Windows Live Mail because WLM Understood that not everyone runs off of an Exchange Email Server and that people often have more than one email account. WLM Had a great feature known as All Inbox which would combine the Inbox from every account that you have. I have found a way around this in Outlook 2013 with a macro to SEARCH for the Inbox folder in All Mailboxes:

    Sub UnifiedInbox()
    Dim myOlApp As New Outlook.Application
        'clear the current search
        'search for emails in all inboxes
        txtSearch = "folder:Inbox"
        myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
        'select the home tab
        Set myOlApp = Nothing
    End Sub

    The problem I am coming across is nothing critical but more cosmetic. The macro runs great, but ALWAYS leaves you on the Search Tab after it is finished running. How can I make the Macro select the Home Tab after running the search?

    Sunday, February 16, 2014 9:21 PM


  • Unfortunately, ribbon handling doesn't work in Outlook VBA. It requires a COM addin. There'd be no way to get a handle to the ribbon to be able to call ActivateTabMso().

    The SendKeys hack is about the only way.

    Ken Slovak MVP - Outlook

    • Marked as answer by Marvin_Guo Tuesday, February 25, 2014 1:52 AM
    Monday, February 17, 2014 3:23 PM

All replies