+ Reply to Thread
Results 1 to 17 of 17

how to attach a worksheet and email it

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    how to attach a worksheet and email it

    i have this test code that is working as expected

    Please Login or Register  to view this content.
    so it picks a sheet based on the target.row, saves it and then attaches it to an email and it sends. everything so far is good.

    then i tried to put it in my other spreadsheet and it doesn't work. it fails on the attachment line. what am i doing wrong?

    Please Login or Register  to view this content.
    here is the line it fails on:

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487

    Re: how to attach a worksheet and email it

    Does the msgbox work?

  3. #3
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to attach a worksheet and email it

    yes it displays the proper filename and extension.

  4. #4
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to attach a worksheet and email it

    thoughts anyone?, still haven't been able to get this fixed.

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487

    Re: how to attach a worksheet and email it

    What is the error?

  6. #6
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to attach a worksheet and email it

    RunTime Error 287 - application-defined or object-defined error

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487

    Re: how to attach a worksheet and email it

    I can't see where you defined x

  8. #8
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to attach a worksheet and email it

    Please Login or Register  to view this content.
    when i msgbox x, it tells me the correct filename and extension.

  9. #9
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487

    Re: how to attach a worksheet and email it

    I am not sure, if your "y" works, but your "x" doesn't then there must be something missing. The msgbox box is just displaying a string, the attachment has to be something that exists.

    You haven't shown the complete code, so we can't see where you dim'd the variables.

  10. #10
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to attach a worksheet and email it

    @Dave

    I can verify that the file is getting saved properly. in my sample test case, i have it working just fine. just can't get it to work in my other macro. how can i debug this?

    should i upload the sample and the working workbooks for you to take a look at?

  11. #11
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487

    Re: how to attach a worksheet and email it

    Sure send a sample workbook

  12. #12
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to attach a worksheet and email it

    so now my test wb is failing on the same line. so i'll just upload the sample workbook.
    Attached Files Attached Files

  13. #13
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487

    Re: how to attach a worksheet and email it

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    is not part of the code, you have it commented out,

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    -errors because it is not a filename.

  14. #14
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to attach a worksheet and email it

    yup, i didn't check well enough so thanks for picking that up. so i went back to my test workbook and figured out how to make it work again. so below is what i have. the only thing that is missing is that i want it to email the selected row and attach a spreadsheet. what it is doing now is emailing the sheet and attaching the sheet, not what i want. can you suggest how to make this work like i want?

    Please Login or Register  to view this content.
    i tried this line but it error'd out

    Please Login or Register  to view this content.

  15. #15
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to attach a worksheet and email it

    thoughts anyone?

  16. #16
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487

    Re: how to attach a worksheet and email it

    I don't know, your code is too busy, attached is a simple example using this code.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  17. #17
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to attach a worksheet and email it

    yup, i tried your code and indeed it copies the row. but when i put in the attachment code, then its back to copying the worksheet. i'll keep trying to modify the code. thanks for your help.

+ 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] export worksheet and attach to email
    By adamheon in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-31-2016, 04:17 PM
  2. attach different worksheet and email them tdifferent email address through macro/vba/addin
    By arunverma004 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-03-2014, 08:20 AM
  3. [SOLVED] Email Macro to attach a non active worksheet to outlook email
    By mickgibbons1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-21-2013, 08:38 PM
  4. Replies: 0
    Last Post: 03-14-2013, 01:27 AM
  5. How do I attach an Excel Worksheet to an email?
    By Verity in forum Excel General
    Replies: 3
    Last Post: 01-24-2007, 11:13 AM
  6. [SOLVED] How do I attach just one Excel worksheet in an email
    By Fernando Moreno in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2006, 02:20 PM
  7. Replies: 1
    Last Post: 09-28-2005, 02:05 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