Raymond Osterbrink
Raymond Osterbrink

Reputation: 540

How to check for the active Application?

I made a VBA-Macro, activated via a Ribbon-Button for exporting selected Mails into a certain folder.

I'd like to make this Macro available in Word and Excel (for exporting doc/xls) into the same folder-structure.

Is it possible to check for the active application and then decide if a Mail(s)-Export or a simple Doc/Xls-Export should be done?

Upvotes: 1

Views: 5728

Answers (1)

user2140173
user2140173

Reputation:

If you are working with multiple Applications probably the easiest way to identify one would be to use Application.Name property.

If you happen to have passed an object of some type that has the .Application property you can also call that. Refer to this post for details.

Also, with most MS-Office objects you can go up the hierarchy using the .Parent property to get all the way up to the Application, ie. .someObj.Parent.Parent.Parent.Application.Name

Upvotes: 1

Related Questions