Share via

Outlook VBA: Getting Reference to Calling Object

Anonymous
2022-05-06T19:46:45+00:00

I am generally decent with using VBA with the exception of Outlook. I am wanting to convert one of my "Quick Steps" to a macro, to which I will then assign it to a Quick Access Toolbar (QAT) button. The reason for this is that I use this quick step very frequently throughout the workday and deal with a lot of attachments, and when selecting an attachment the ribbon changes from the 'home' tab to the 'attachment' tab within the email - making this quick step slightly less "quick" as I have to now click on the home tab again.

I am needing a way for the macro to first establish where it was called from (whether from Outlook main application or from an open email) then assign the message to an obj variable to allow me to manipulate it the way the quick step does.

1.) How do I allow the macro to determine whether it was called from the Outlook app?

1a.) I shouldn't have an issue assigning the selected message to a mail obj variable, but feel free to share some insight if you wish as I am mostly unfamiliar with Outlook object model.

2.) How do I allow the macro to determine if it is being called from an open mail object?

2a.) How do I assign this particular mail object to a variable? Is Application.ActiveInspector.CurrentItem the appropriate way to accomplish this, or is there a better way to get the caller's object? Application.Caller doesn't appear to be a thing in Outlook.

The reasoning being parts 1 & 2 is to allow me to use the macro regardless if it's being called from the main program or from within the email.

I am using Outlook 2016 if that helps.

I greatly appreciate any assistance on this!

Outlook | Windows | Classic Outlook for Windows | For home

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2022-05-07T05:11:13+00:00

    Hello K.Davis,

    Welcome to Microsoft Community.

    According to your description, seems your concern is related to Outlook VBA and macros. Regarding this point, we are sorry to tell you that this run out of our support scope. However, for VBA issues we have a dedicated forum that has abundant experience with this, we kindly suggest you post this question in Microsoft Q&A. Experts in there might be available to resolve this issue for you.

    Kind Regards,

    Tommy

    Was this answer helpful?

    0 comments No comments