Avatar of hindersaliva
hindersalivaFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

How to get Outlook hand control back to Excel VBA procedure?

I have an Excel VBA procedure that sends emails from am Outlook Template (.oft). That works fine.
I'd like to put at the top of the process a .Display so that the template is displayed for the user to check that it is the correct one.

Is it possible to make the Excel VBA to continue running when the user Closes the displayed Outlook template? I think this would need something like the 'close' in Outlook triggering a procedure in Excel. Would that be possible?

Thanks
OutlookMicrosoft ExcelVBA

Avatar of undefined
Last Comment
hindersaliva
Avatar of Anastasia D. Gavanas
Anastasia D. Gavanas
Flag of Greece image

Can you provide a snippet of your code so we can understand better?
Avatar of hindersaliva
hindersaliva
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

This displays the template. OK.

Sub PreviewEmails()

    Dim myOlApp As Outlook.Application
    Dim oMail As Outlook.MailItem
    Set myOlApp = CreateObject("Outlook.Application")
    
    strTemplateName = "Template1"
    strTemplateFolder = "C:\Samples\Sending emails\"
    strPath = strTemplateFolder + strTemplateName
    
    Set oMail = myOlApp.CreateItemFromTemplate(strPath)

    oMail.Display

End Sub

Open in new window


My question is, when the user closes the displayed template (with close box) is it possible for that event to run/call an Excel VBA procedure?
ASKER CERTIFIED SOLUTION
Avatar of Anastasia D. Gavanas
Anastasia D. Gavanas
Flag of Greece image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of hindersaliva
hindersaliva
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Hi xtermie, I shall need to learn more about that. Thanks. I'll close the question.
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo