+ Reply to Thread
Results 1 to 8 of 8

Creating email attachment out of excel - so close yet so far...

  1. #1
    Registered User
    Join Date
    10-10-2013
    Location
    Amsterdam, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    4

    Creating email attachment out of excel - so close yet so far...

    Hi,

    I have the following sub which creates an email in Lotus Notes using the output of my query in excel.

    Please Login or Register  to view this content.
    It works, the output is a .csv file with the range of rows that I have in excel except that it also includes the remaining 65000 empty lines as a string of commas (,,,,,,,,,,,,,,,,,,) underneath. I dont understand why since in the selection.copy I really only get the rows filled by my query.

    Anyone have an idea how to create a temp .csv file with only the rows that I select in the selection.copy part of the code? Any help will be greatly appreciated!

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Creating email attachment out of excel - so close yet so far...

    The following code may be causing this

    Please Login or Register  to view this content.
    The first range statement may not be doing what you expect. In particular the 'Selection.End(xlDown)' may yield strange results

    You could try the code below (note I have also set SkipBlanks to True as this only refers to empty cells at the end of the selection)

    Please Login or Register  to view this content.
    If you like my contribution click the star icon!

  3. #3
    Registered User
    Join Date
    10-10-2013
    Location
    Amsterdam, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Creating email attachment out of excel - so close yet so far...

    Hi OllieB,

    Thanks for the reply! I should clarify that I do not see a problem in the selection part of the code, I used your suggestion and the results do not vary, it really seems like I am missing something in the step between converting that selection into the .csv file.
    Attached Images Attached Images
    Last edited by malikazam; 10-10-2013 at 05:36 AM.

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Creating email attachment out of excel - so close yet so far...

    malikazam,

    under certain conditions Excels loses track of the last row actually used on a worksheet. You can check this by opening the worksheet manually, position the cursor on cell A1 and pressing {Ctrl}{Shift}{End} simultaneously. If all is well the selection shown should only encompass a range of cells that have values. If things are wrong it will select pretty much the entire worksheet. Can you check this for me.

  5. #5
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Creating email attachment out of excel - so close yet so far...

    Another solution you could try is to copy & paste the range used onto a new empty worksheet and saving that new worksheet as a CSV. That would also save you the work of removing columns, rows etc, and I am pretty sure that will solve you problem altogether.

  6. #6
    Registered User
    Join Date
    10-10-2013
    Location
    Amsterdam, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Creating email attachment out of excel - so close yet so far...

    Hi OllieB,

    {Ctrl}{Shift}{End} select A1:AE65536.

    Unfortunately, the user for this sheet is too lazy to agree with your alternate solution

  7. #7
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Creating email attachment out of excel - so close yet so far...

    You could try to use the below code to generate the CSV

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-10-2013
    Location
    Amsterdam, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Creating email attachment out of excel - so close yet so far...

    Hi OllieB, once again many thanks for your help. I cannot seem to incorporate your code into my initial sub. In the meantime I have convinced my client to just copy and paste into a different sheet and save as .csv :D

+ 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. Export Email Attachment to Excel
    By dwhite30518 in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 05-30-2012, 06:08 PM
  2. Creating email from excel list with attachment
    By Trassin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-25-2011, 07:44 AM
  3. email excel file or worksheet as an attachment to multiple email addresses
    By jgeagle5 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-16-2009, 03:40 PM
  4. attachment - then email from excel!
    By dj_siek in forum Excel General
    Replies: 0
    Last Post: 02-14-2006, 10:10 PM
  5. cant send email attachment from excel
    By DKT in forum Excel - New Users/Basics
    Replies: 8
    Last Post: 11-21-2005, 09:30 PM

Tags for this Thread

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