I have a function in the outlook VBA that I want to call when a certain excel workbook is closed. Is there a way to do this with the BeforeClose event of excel? I know how to write functions for this event, but I am not sure how to link them to the current outlook session to get to the function.
Call outlook VBA from Excel
19.2k Views Asked by loveforvdubs At
2
There are 2 best solutions below
2
i_saw_drones
On
If you wish to get hold of a reference to an instance of Outlook that is already running, you will need to use:
Set myOutlookApp = GetObject(,"Outlook.Application")
which will give you access to the Outlook application object so you can call your desired VBA function in Outlook:
myOutlookApp.MyFunctionToExecute()
You'll probably need to make the function Public otherwise Excel's VBA might not be able to see it.
Related Questions in EXCEL
- Power Query / M Code, extract a list of tables into one main table, some column headers same but some different and in different order (and in row 2)
- Is there a way to validate the cell format (from excel) to fetch the symbol from it (in Java)?
- Excel - Visual Basic, macro with autofill "1"
- Getting Run-time error '13': Type Mismatch using .Find
- Getting website metadata (Excel VBA/Python)
- Excel Code Editor doesn't work (blank window)
- How to find out how many of each 2, 3 and 4 required to fit in 100 using excel?
- How would I apply a rather complex summation formula like this in Excel?
- Removing a Button from Customized Excel Ribbon
- Excel - Update Item Description Based on Accessories Ordered with It
- select duplicates from data based on another column
- How to use VBA to bold just some text
- VBA Code to filter and get values from csv to excel worksheet
- Look up max alpha numeric value
- Azure Batch for Excel VBA
Related Questions in VBA
- Toggle "conversation view" in Outlook with VBA
- VBA query - sort text in alphabetical order in Word
- Excel - Visual Basic, macro with autofill "1"
- Getting Run-time error '13': Type Mismatch using .Find
- Getting website metadata (Excel VBA/Python)
- How to use VBA to bold just some text
- VBA Code to filter and get values from csv to excel worksheet
- Azure Batch for Excel VBA
- How can i printpreview multiple excel sheets, with the names of the sheets located in a range?
- Comparison the data of two row and unique number highlight and show below of it
- Is there a way to pass Today's date as a command line argument to Excel from a Windows Task Scheduler Job
- Xero Upload Invoice file using API
- Visual Basic For Application Related Question
- Trying to give color to column field headers in pivot table with vba
- General error handler: If any error in UserForm other than msgBox: Err.Description
Related Questions in OUTLOOK
- Toggle "conversation view" in Outlook with VBA
- Error 553 5.7.2 [TSS09] When Sending Emails to Yahoo and Outlook
- Hide canceled meeting invites on outlook
- outlook vsto add-in can't find contact
- Using MAPI to open an Outlook folder, MAPIFolder.Items.Sort("Subject",True) does not sort
- office.js item.close() and inline replies in outlook
- How does outlook disable screenshot
- menu item in plugin for outlook using c# VSTO
- RSVP Section or button not showing in Outlook and Zoho in Laravel
- How to bulk upload events into Outlook Calendar via a csv file while preserving line breaks in the description?
- Creating a outlook calendar event leaves a shade of that event throughout the entire day till the end date
- I'm not getting notified on my email client i.e., outlook despite they're in firing state
- Alerts are not displaying in the Alertmanager UI and I'm not getting notified on my email client i.e., outlook despite they're in firing state
- Storing the state of a VSTO Outlook plugin in a draft message
- Rewriting CSS in MSO conditional comment doesn't work
Related Questions in EXCEL-2007
- How to read Raw value rather then the formatted value from the excel sheet using POI library using XSSFReader class
- How to sort data in text format in Excel
- Check excel file is protected (with and without password)
- How to exclude insecured download blocked warning in Edge
- In Excel apply formula by vlookup from Sheet1 to Sheet2 in VBA
- Need accessibility related help for VBA generated combo box
- Is there a formula to Count Unique values with Criteria and between two dates
- How to determine the count of Worksheet Tabs that is visible in the Sheet Tab on Excel?
- Is there a formula to multiply two column only if both of them not null?
- How to change a cell value in worksheet change event in vba
- Identifying number of sequential numbers in a set of data in Excel
- Formula cell in excel shows #NAME?
- Error Changing a range of cells withing the same row
- Python returns Excel formula rather than cell value or the cell value isn't changing
- Bring back value from specific cell in Excel after each combination was entered
Related Questions in OUTLOOK-2007
- outlook 2007 - 2019 css issue for Email templates
- Outlook calendar event cancel
- How can I middle align both text and image in present in a single td tag for an email to be rendered in outlook?
- Outlook emails extra space in TD cells
- Is there any way to know if the user pressed "send" or "X" button after the new mail window opened via outlook from powerbuilder?
- Outlook Add-In: The UI is different for web and Windows Desktop app
- Outlook Add-In: AppointmentTimeChanged Event not getting triggered on changing the time of the event
- How to change email body format to HTML from an Outlook VSTO add-in?
- Outlook add-in custom command line switch
- Is it possible to have two background images behind text?
- Fetch Email Address for SentOnBehalfOfName in outlook 2007 VSTO code
- Outlook 2007 Add in not loading in outlook on xp
- 2 Column Responsive Email in Outlook 2007, 2010
- could not send a mail using SMTP server and AJAX
- Embed form in outlook email and capture response
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
MS Office applications can interact with each other by this method (this is based on Office 2007, but others will be similar):
Add a reference to the app into Excel
In Excel VBA, from the Tools\References menu select Microsoft Outlook 12.0 Object Library
In your BeforeClose Event include
You can now access Outlook through the olApp object. I don't know much about the Outlook object model, so others may be able help more from here on...