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
- Concatenate excel cell string within cell reference string
- Use hidden information for filtering data
- Using Vlookup in Excel sheet to match substring
- Import from api into multiple excel cells
- Loop through list of files and open them
- Pull and push data from and into sql databases using Excel VBA without pasting the data in Excel sheets
- Loop with equation for upper limit
- excel vba null value in array
- Why is my xml file having these after convert from excel?
- TextToColumns function uses wrong delimiter
- Difference between two dates in excel 2013
- Concatenate string and number as number
- Why in a pivot the "include new items in manual filter" option is grey out when source is a powerpivot?
- Count Unique Values Repeated Dates
- How do I extract info from crunchbase
Related Questions in VBA
- Import from api into multiple excel cells
- Loop through list of files and open them
- Pull and push data from and into sql databases using Excel VBA without pasting the data in Excel sheets
- Loop with equation for upper limit
- excel vba null value in array
- TextToColumns function uses wrong delimiter
- Access Global not working
- Concatenate string and number as number
- How do I extract info from crunchbase
- Excel needs to pull substring values to variables
- Act on Outlook mail item when opened for editing
- Macro is not working
- Excel 2013 VBA opening multiple windows for a single workbook
- Hyperlink directs to hidden row
- How to modify data in a range of a column of cells that are not blank
Related Questions in OUTLOOK
- Act on Outlook mail item when opened for editing
- Outlook MailItem HTML Formatting Dropdown
- Is there such thing as Outlook Message Delimiter?
- EWS Service.FindItems() throws an exception when using SearchFilter.IsEqualTo
- How to show the appointment page from a form region in outlook
- How to be sure Outlook application has been loaded completely (application.StartUp event)
- Outlook 2013: select multiple emails and autoreply using template
- Access VBA To Send Query Results to Outlook Email in Table Format
- Visual Basic - Screen shot then insert into email
- create a outlook add-in to popup an input text field form for user info
- Table width does not work in Outlook 2010
- Modify background color of MailItem in Outlook 2013 Inbox
- Getting Outlook Window from VSTO Addin
- Too many mistakes: String not correct _1 ; Controlsend?
- Outlook 2013 VBA Public Variable Doesn't Persist
Related Questions in EXCEL-2007
- COUNTIFS to ignore hidden rows excel 2007
- is there a shortcut to open filter>contains box in excel?
- Always Return the Previous Saturday's Date Using NOW Function in MS Excel 2007
- Creating a dynamic charting macro in VB
- Returning just the date portion of =NOW()-(WEEKDAY(NOW(),1)) in Excel 2007
- How do I populate an Excel field with changing web data?
- Strange number-of-character-in-a-cell limitation when programmaticaly (VBA, C#) set array string to a range
- Look back through a row and find the last time I wrote a particular word
- Add a Macro Button to a Worksheet Using the Aspose.Cells API
- Excel 2007 Calculations
- Changing the active cell
- Why would Excel 2013 data validation cell range change after upgrading from 2007?
- Typed Data between Excel and VB.Net
- VBA ErrorHandler MsgBox Syntax
- Declare a variable as Decimal
Related Questions in OUTLOOK-2007
- How do you delete favorite folders in outlook using VBA
- How to create mail using Mail::Outlook with Outlook 2007
- Outlook Application_NewMailEx not working on startup
- Create MAPIFolder object in C# on non default Outlook 2007 account
- Attachment.Delete fails for 2007
- "list-style-type: none" does not work in Outlook 2007
- Outlook COM Add-in: Application_NewMail not getting fired
- Automatic Email Function
- Background image in td for Outlook 2007
- _Really_ disable reminder via ics in Outlook
- NEED SUGGESTION: How to write a Microsoft Outlook Add-In that can select multiple GROUPS(folders) of contacts all at once?
- Where can I find out more about the Outlook 2007/Microsoft word html layout engine?
- Are Outlook 2007 File Picker Dialogs customizable?
- User settings disappear on outlook upgrades
- Outlook 2007 Add-in Send Update
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 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...