+ Reply to Thread
Results 1 to 17 of 17

Using code to email a sheet but need to strip the code before sending

  1. #1
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Using code to email a sheet but need to strip the code before sending

    Hi, I am using the code below that I got off of these forums to email a particular sheet in my workbook, but I need to strip all of the VBA code and the command button from the sheet being sent. Is this possible?

    Please Login or Register  to view this content.
    Thanks!
    Clayton Grove

  2. #2
    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: Using code to email a sheet but need to strip the code before sending

    Hello Clayton,

    Can you post a sample workbook? It would be easier and faster to answer you questions with it.
    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!)

  3. #3
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: Using code to email a sheet but need to strip the code before sending

    Here you go! The button and the sheet I am trying to email is the "CRW Spreadsheet to AR" tab.

    Thanks!

    Clayton Grove


    http://www.4shared.com/file/83957410..._Template.html

  4. #4
    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: Using code to email a sheet but need to strip the code before sending

    Hello Clayton,

    I have worked all day on this workbook trying to get the email to work. You are SOL on this one. No matter what I do, it will not work. The same code worked on other workbooks. This file is demon spawn and should be cast in the fires of eternal damnation! Sorry, I got nothing.

  5. #5
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: Using code to email a sheet but need to strip the code before sending

    wow.... I am not quite sure what to say... If you can't do it I am fubar'ed. Thanks for giving it a shot.



    Clayton

  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: Using code to email a sheet but need to strip the code before sending

    Hello Clayton,

    I thought perhaps it was due to the links in the workbooks that was causing the problem. However, even including code to break all the links in the copy, had no effect. If you don't need the formulas to be functional, we have a chance. Let me know.

  7. #7
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: Using code to email a sheet but need to strip the code before sending

    All I really need is the results of the formulas on the sheet that is emailed. So the formulas do not have to be functional in the copy that is being atatched to the email.

    Thanks!
    Clayton

  8. #8
    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: Using code to email a sheet but need to strip the code before sending

    Hello Clayton,

    LOL! I should have asked before I started pulling my hair out! I had a Navy instructor who always told us "There is only one dumb question - the one you never ask." I'll start recoding it to use only the values from the worksheet. By the way, will everyone who receives the email be using Outlook?

  9. #9
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: Using code to email a sheet but need to strip the code before sending

    I don't know about the people receiving but the people sending the sheets will be using outlook.

    Thanks again for your help!
    Clayton

  10. #10
    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: Using code to email a sheet but need to strip the code before sending

    Hello Clayton,

    The format will be plain text (no color, lines, etc.) just the values in rows and columns. If everyone were using Outlook, the worksheet could be emailed as is using HTML. Better to make it as universal as possible.

  11. #11
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: Using code to email a sheet but need to strip the code before sending

    plain text is fine. I think the Data is imported into a database after it has been sent on so HTML would probably not work.

  12. #12
    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: Using code to email a sheet but need to strip the code before sending

    Hello Clayton,

    Maybe the server will let me post the workbook this time. I have been trying since late last night to get this to you. I fixed it and it is working. There is too much code to post here. I will post the workbook when the server is working. In the mean time, I could email it to you. You could then let me know how it works.

  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: Using code to email a sheet but need to strip the code before sending

    Hello Clayton,

    Here is the working version of the workbook. Perhaps this will work as a zip file. Finally, success!
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: Using code to email a sheet but need to strip the code before sending

    Hi Leith, thank you for helping me out on this. When I click on commandbutton1 to start the macro I am getting an error that says Run-time error 1004: Method 'VBE' of object'_Application' failed.

    When I debug it highlights this line:
    Please Login or Register  to view this content.
    Any Ideas?

    Clayton

  15. #15
    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: Using code to email a sheet but need to strip the code before sending

    Hello Clayton,

    What version of Excel are you using?

  16. #16
    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: Using code to email a sheet but need to strip the code before sending

    Hello Clayton,

    I just checked Excel 2000 and the statement exists and the same version of the object library is used. The reference to the Visual Basic for Applications Extensibility object library should have been loaded when the workbook opened. Check the references in the Visual Basic Editor: Tools > References... It will tell you if something is missing.

  17. #17
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: Using code to email a sheet but need to strip the code before sending

    I am using 2003.

+ 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