+ Reply to Thread
Results 1 to 8 of 8

Macro to close outlook

  1. #1
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Macro to close outlook

    Is it possible to have a macro that will close outlook after the outbox is empty? maybe set a 10 sec delay timer at end of code.Have a code in excel to open outlook,now I would like a way to auto close after the file from excel is out of the outbox. If file is not sent then outlook stays open. Not sure if a macro from excel can do this,I still need to open outlook and send emails when outbox is empty.

    Thanks for any suggestions.
    Last edited by zplugger; 01-16-2017 at 07:14 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to close outlook

    Not sure I understand the problem

    The procedure below is a generalised version of one I use a lot - (based on one of Ron de Bruin's examples)

    With the .Display and .Close(0) commented out the email is sent and closed automatically.
    If you choose to use the .Display allowing you to view the email then the .Close(0) line is the one that will close the email but of course since you're able to view the email you could close it anyway.
    Please Login or Register  to view this content.
    Can you clarify the point you're making?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Macro to close outlook

    Thanks Richard
    Sometimes the email will get hung up in the outbox,if I don't catch it it will stay there.Looking for a idiot message box telling me message was sent and do I want to close program.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to close outlook

    Please Login or Register  to view this content.
    i just took the syntax of checking if outbox is empty from here
    https://www.experts-exchange.com/que...in-Outbox.html

    worked on my test setup
    believe it only checks the default outlook account not all accounts so if this is not the case...cross that bridge later if needed
    Last edited by humdingaling; 01-16-2017 at 02:15 AM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to close outlook

    oh forgot the closing outlook bit

    Please Login or Register  to view this content.
    Code seems to work better if Outlook is open
    so left the outlook open check in there
    Last edited by humdingaling; 01-16-2017 at 02:11 AM.

  6. #6
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Macro to close outlook

    Nice piece of work,this is a good start. Is there a way I could put this code in BeforeWorkbook Close event and make it work ?

  7. #7
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to close outlook

    dont see why this code couldnt just be plugged into the Workbook_BeforeClose Event

    what error are you getting when you tried this?

  8. #8
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: Macro to close outlook

    My mistake, its works perfect. Thank You so much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Issue with Open, copy, close Macro - when trying to close workbook Clipboard error
    By seanpcorbett1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-13-2016, 05:14 PM
  2. open outlook then close before email is sent using vba
    By cmccabe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2016, 03:52 PM
  3. How to open and Close ms outlook??
    By uttam.mothe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-02-2014, 09:12 PM
  4. [SOLVED] VBA script to close Excel file opened in Outlook
    By Metrazal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2014, 09:59 AM
  5. Close Outlook from Excel with Delay
    By zplugger in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-24-2014, 10:09 AM
  6. Auto Close Idle Outlook
    By zplugger in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 02-23-2014, 03:36 PM
  7. [SOLVED] Excel Exits on File Close with Outlook
    By Erin Searfoss in forum Excel General
    Replies: 1
    Last Post: 01-16-2005, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1