Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    May 2006
    Location
    Charlotte, North Carolina, USA
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Email Attachment (2003 SP2)

    I have a database that creates over 500 excel spreadsheets with the file name different for each one. Each one will have a different district number and today's date in the file name. Example (SM_PAYMODELER_DIST029_04032007.xls). I have this code written to send each of the files out as an attachment, but something is not formatted correctly because I keep getting the error that the file cannot be found. This is the code:

    myattachments.Add "NCMAINUSERSCOMMON_HRHRISPAY MODELERSM_PAYMODELER_DIST" & strDist & "_" & Format(Now(), "MMDDYYYY") & ".xls", olByValue, 1, "Store Manager Pay Modeler"

    I know the path is correct because when I change the code to add the actual file name itself (SM_PAYMODELER_DIST029_04032007.xls) it runs correctly. I just need it to pick up the files with that format. So something is wrong with the way I'm formatting the file name.

    Thanks :-)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email Attachment (2003 SP2)

    Try this:

    Dim strAttachment As String
    ...
    strAttachment = "NCMAINUSERSCOMMON_HRHRISPAY MODELERSM_PAYMODELER_DIST" & strDist & "_" & Format(Now(), "MMDDYYYY") & ".xls"
    msgbox strAttachment
    myattachments.Add strAttachment, olByValue, 1, "Store Manager Pay Modeler"

    This will display the generated path and filename in a message box before trying to attach it. Check carefully that the path and filename is as intended.

  3. #3
    New Lounger
    Join Date
    May 2006
    Location
    Charlotte, North Carolina, USA
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email Attachment (2003 SP2)

    Thanks! I was able to pin point the problem and correct it :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •