+ Reply to Thread
Results 1 to 14 of 14

Email worksheet via command button

  1. #1
    Registered User
    Join Date
    05-21-2010
    Location
    Wellington, New Zealand
    MS-Off Ver
    2003, 2007
    Posts
    16

    Email worksheet via command button

    Thanks in advance for your time, I'm a new user with a project that is way over my head. I'm very grateful for all help.

    I am setting up a request template in an Excel worksheet. Once it has been filled out, the requester will click 'Submit' and, after checking that the required fields are completed, the sheet will be emailed as an attachment either

    1 ) to the service desk, if the content of B3 is 'Yes' or, if the content is "No" or Blank,
    2) to the email address in D58.

    I can't work out how to get the sheet emailed.

    This is what I've got so far:

    Please Login or Register  to view this content.
    (In case you were wondering, the bit that says "address" has the actual email address in it).

    Thanks!
    KaFi
    Last edited by KaFi; 05-27-2010 at 11:51 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Email worksheet via command button

    See http://www.rondebruin.nl/sendmail.htm
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Email worksheet via command button

    Hello Kafi,

    This macro is tailored to what you want. Copy this code into a VBA module. Make the changes you need to the recipient address,the message you want to send and the emailed workbook name.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    05-21-2010
    Location
    Wellington, New Zealand
    MS-Off Ver
    2003, 2007
    Posts
    16

    Re: Email worksheet via command button

    Thanks Leith, much appreciated!

    The email message creates beautifully, but the email address is not coming across - the To: field in the message is blank, regardless of which address it's using. Any thoughts about what may be causing this?

    Cheers
    KaFi

  5. #5
    Registered User
    Join Date
    05-21-2010
    Location
    Wellington, New Zealand
    MS-Off Ver
    2003, 2007
    Posts
    16

    Re: Email worksheet via command button

    Thanks shg, that link is an excellent resource. I'm checking it out now.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Email worksheet via command button

    Hello KaFi,

    Post the code as you have it now. My testing of the macro worked fine. Obviously, something is different.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Email worksheet via command button

    or

    Please Login or Register  to view this content.
    Last edited by snb; 05-27-2010 at 03:39 AM.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Email worksheet via command button

    Think you need a little more punctuation in that, snb.

  9. #9
    Registered User
    Join Date
    05-26-2010
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Email worksheet via command button

    Hi,
    what the change need to be made if am using outlook express instead of MS Outlook.

    Regards
    Vinoth

  10. #10
    Registered User
    Join Date
    05-21-2010
    Location
    Wellington, New Zealand
    MS-Off Ver
    2003, 2007
    Posts
    16

    Re: Email worksheet via command button

    Hi Leith

    Thanks for following up. I think I must have put it in the wrong place - I've pasted the code you gave me below, in context with the info around it:

    Please Login or Register  to view this content.
    My thinking was to put the code under the other things that needed to happen when the Submit button is clicked. Can you set me straight?

    Regards
    KaFi

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Email worksheet via command button

    Hello KaFi,

    I can sort the code out better if you post the workbook.

  12. #12
    Registered User
    Join Date
    05-21-2010
    Location
    Wellington, New Zealand
    MS-Off Ver
    2003, 2007
    Posts
    16

    Re: Email worksheet via command button

    Thanks - posted below.

    cheers
    Kafi
    Attached Files Attached Files

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Email worksheet via command button

    Hello KaFi,

    The problem appears to be we were referencing cell "B3" when we should have been referencing "B53". I made the change. You should also change the default email address in the macro to a real address. Here is the revised macro. I indented the code to make it easier to read. The macro has been added to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    05-21-2010
    Location
    Wellington, New Zealand
    MS-Off Ver
    2003, 2007
    Posts
    16

    Talking Re: Email worksheet via command button

    Oh - sorry, I should have proofed it properly. Thanks again for your help and your patience, this is now working perfectly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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