+ Reply to Thread
Results 1 to 3 of 3

Attach files to E-mail based on partial filename

  1. #1
    Registered User
    Join Date
    07-07-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    2

    Attach files to E-mail based on partial filename

    Hi All,

    I'm currently creating E-mails containing a table of material numbers in the body of the message. The E-mail is generated with a macro from a table in excel. In some folder - say on the desktop - I have PDF files for each material Number. Each file is called 0012345_Product-Name.pdf where 0012345 is the material number (always 7 digits). I want the macro to look for the pdf for each material number found in the table and add it to the E-mail as an attachment. With constant, known file names this wouldn't be much of an issue. However, I'm having trouble getting the macro to only search for the first 7 digits of the filename and select it based on that. Is there any way of doing this?

    Thanks!
    P.s.: Since we are talking up to several 100 PDF's, it would also be great to zip them, once selected - if at all possible, before attaching them to the E-mail
    Last edited by MUCa346; 07-31-2014 at 10:48 AM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Attach files to E-mail based on partial filename

    To find the correct file, for a list of parts starting in cell A2, for example:


    Please Login or Register  to view this content.

    For the zipping part:

    http://www.rondebruin.nl/win/s7/win001.htm
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    07-07-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    2

    Re: Attach files to E-mail based on partial filename

    Thanks for the help! I've got it to work that far, and have no issues, attaching the files to an E-mail. Turned out a lot simpler than anything I was thinking about. I did play with rondebruin's code's a bit after posting yesterday. I tried working them with your code but it seems to get hung up. It never gets beyond:
    Please Login or Register  to view this content.
    It simply stays there for hours, even when just zipping up one or two 100kb files..
    Here's the full code for this part:

    Please Login or Register  to view this content.
    Any suggestions?

+ 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. Open up a Lotus Notes Database (not mail) create a new post and attach files VBA Excel
    By exceliscool in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-12-2014, 03:25 PM
  2. If statement based on partial filename
    By sperry2565 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2013, 11:44 AM
  3. click on mail address, print specific page to pdf, attach it to mail
    By Crosplit in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-09-2013, 04:54 AM
  4. code to attach the draft mail in new compose mail as attachment in outlook 2010
    By priya1987 in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2012, 08:38 AM
  5. Lookup & open file based on partial filename
    By Im2bz2p345 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2011, 07:04 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