+ Reply to Thread
Results 1 to 19 of 19

send file when press exit

  1. #1
    Forum Contributor
    Join Date
    09-21-2020
    Location
    israel
    MS-Off Ver
    2017
    Posts
    113

    Lightbulb send file when press exit

    hi friends,

    how can ido the file send auto when press exit?

    thanks

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,001

    Re: send file when press exit

    .
    You have not provided enough information to give you assistance.

    Please described in more detail what you are attempting to do and ... post a copy of your workbook displaying how your worksheet is arranged.

  3. #3
    Forum Contributor
    Join Date
    09-21-2020
    Location
    israel
    MS-Off Ver
    2017
    Posts
    113

    Re: send file when press exit

    hi,Sub Mail_workbook_Outlook_1()

    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
    .to = ""
    .CC = ""
    .BCC = ""
    .Subject = "test"
    .Body = "Hi there"
    .Attachments.Add ActiveWorkbook.FullName

    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub



    i want when click exit excel the mail will send auto
    thanks

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,001

    Re: send file when press exit

    .
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    09-21-2020
    Location
    israel
    MS-Off Ver
    2017
    Posts
    113

    Re: send file when press exit

    Thanks, but how do I get the file sent automatically when a user clicks on Exit?

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,001

    Re: send file when press exit

    .
    Connect your "EXIT" button to the macro.

    Right click on the button ... select the macro name and click OK.

    Next time you click no the button, the macro runs and the email is sent ... so long as you have MS Outlook on your computer.

  7. #7
    Forum Contributor
    Join Date
    09-21-2020
    Location
    israel
    MS-Off Ver
    2017
    Posts
    113

    Re: send file when press exit

    Sorry but I did not understand what and where I should add to the macro command.
    I want when the user exits the excel (exits the software) it will send
    Thank you.

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,001

    Re: send file when press exit

    .
    In the ThisWorkbook module, add this :

    Option Explicit

    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
    .to = "Test TO"
    .CC = "Test CC"
    .BCC = "Test BCC"
    .Subject = "test"
    .Body = "Hi there"
    .Attachments.Add ActiveWorkbook.FullName


    .Display '<<---- Comment out "Display" and uncomment " '.Send " when you are
    '.Send 'ready to send emails


    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing

    End Sub

  9. #9
    Forum Contributor
    Join Date
    09-21-2020
    Location
    israel
    MS-Off Ver
    2017
    Posts
    113

    Re: send file when press exit

    thank you vey much
    i have error-
    Attachment 706301

  10. #10
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,001

    Re: send file when press exit

    The attachment did not come through.

    Please use the GO ADVANCED button below the REPLY window. Then click on MANAGE ATTACHMENTS.

  11. #11
    Forum Contributor
    Join Date
    09-21-2020
    Location
    israel
    MS-Off Ver
    2017
    Posts
    113

    Re: send file when press exit

    now its work,i found the problem
    but i want the excel cell copy in body of mail, how i do it?

    Please Login or Register  to view this content.

  12. #12
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,001

    Re: send file when press exit

    .
    Which cell ?

  13. #13
    Forum Contributor
    Join Date
    09-21-2020
    Location
    israel
    MS-Off Ver
    2017
    Posts
    113

    Re: send file when press exit

    Quote Originally Posted by logit View Post
    .
    Which cell ?
    $a$1:$o$28

  14. #14
    Forum Contributor
    Join Date
    09-21-2020
    Location
    israel
    MS-Off Ver
    2017
    Posts
    113

    Re: send file when press exit

    Another question please-
    I want that if "yes" is selected it will save and leave the file without sending an email
    How to perform?
    Thank you.

  15. #15
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,001

    Re: send file when press exit

    .
    Your posted code indicates you want the workbook attached and not to have a range pasted in the message body.

    Do you still want the workbook attached ?

  16. #16
    Forum Contributor
    Join Date
    09-21-2020
    Location
    israel
    MS-Off Ver
    2017
    Posts
    113

    Re: send file when press exit

    Quote Originally Posted by Logit View Post
    .
    Your posted code indicates you want the workbook attached and not to have a range pasted in the message body.

    Do you still want the workbook attached ?
    Yes, i want attached+ message body
    thanks!

  17. #17
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,001

    Re: send file when press exit

    .
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    09-21-2020
    Location
    israel
    MS-Off Ver
    2017
    Posts
    113

    Re: send file when press exit

    Quote Originally Posted by oriazria View Post
    Another question please-
    I want that if "yes" is selected it will save and leave the file without sending an email
    How to perform?
    Thank you.
    thanks
    what about this?

  19. #19
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,001

    Re: send file when press exit

    .

    Paste this in Module 1 :

    Please Login or Register  to view this content.

    Paste this in ThisWorkbook Module :


    Please Login or Register  to view this content.

+ 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. Press button, send email
    By RankSinatra in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-06-2018, 01:29 AM
  2. Send Email when I press "Send" button in Outlook
    By qzqzjcjp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-27-2015, 09:37 AM
  3. [SOLVED] On Button Press Send Value to Selected/Active TextBox?
    By NewYears1978 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-22-2015, 01:02 PM
  4. How to AutoSave backup when press exit button on userform
    By z-eighty2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-09-2014, 04:51 AM
  5. [SOLVED] exit sub when press cancel button on userform
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2014, 01:13 AM
  6. Press submit button and send data to Access
    By Charonix in forum Access Tables & Databases
    Replies: 1
    Last Post: 01-08-2014, 02:34 PM
  7. [SOLVED] Press a button to SEND data from one worksheet to another based on conditions set by user
    By nenadmail in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-21-2012, 10:30 AM

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