+ Reply to Thread
Results 1 to 5 of 5

Create email and attach PDFs from anywhere within a folder and subfolders

  1. #1
    Registered User
    Join Date
    12-08-2015
    Location
    Birmingham, England
    MS-Off Ver
    2007
    Posts
    44

    Create email and attach PDFs from anywhere within a folder and subfolders

    Hi,

    I have the attached code which searches for files within a folder and attaches them to an email. The issue is that it only searches the main folder whereas I need it to search all of the sub folders too. Any suggestions at all please?

    Please Login or Register  to view this content.
    I think this part needs to be modified somehow but I can't work it out.

    Please Login or Register  to view this content.

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Create email and attach PDFs from anywhere within a folder and subfolders

    ummmm....didn't you already post something about this? I remember your name, and I also remember helping someone else out with looping subdirs. I can't find that thread, however does this help you out?

    https://www.excelforum.com/excel-pro...ml#post5399775

    the getFolder() method can be used to point to a main dir, and then you can loop the subdirs in it by way of using the subfolders property.

  3. #3
    Registered User
    Join Date
    12-08-2015
    Location
    Birmingham, England
    MS-Off Ver
    2007
    Posts
    44

    Re: Create email and attach PDFs from anywhere within a folder and subfolders

    Hi, no sorry that wasn't me. I did find this link which seems like it might be what I'm after but I'm not sure how to implement it with my code. https://analystcave.com/vba-dir-func...e-directories/

    I just have a list of PDF files in a column that I want to find anywhere within a folder/subfolder and attach them to an email.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,444

    Re: Create email and attach PDFs from anywhere within a folder and subfolders

    .
    If it will help you, the following macros have been tested to recursively look through a Folder and its Subfolders for XLSM files (all of them). Perhaps you can edit this to suit your needs ?

    Please Login or Register  to view this content.

  5. #5
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Create email and attach PDFs from anywhere within a folder and subfolders

    As you can see what he did, that's exactly what I said previously that you should be doing. The only difference between what I said and what he just did is that he's using the get folder method and the subfolders collection in the same line of code whereas I told you to do it in two different lines of code but it doesn't matter it accomplishes the same goal

+ 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. [SOLVED] How to attach PDFs from desktop folder to various emails?
    By lapot in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 04-15-2020, 11:12 AM
  2. attach file in an outlook email from specific folder
    By 9599lorenzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2017, 07:07 AM
  3. Trying to use MkDir to create new folder with multiple subfolders
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-30-2016, 12:39 AM
  4. [SOLVED] Loop Through Folder, Create Emails with Sub Folder Names in Subject, Attach files in sub
    By Rschwar23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2015, 10:06 AM
  5. Help with macro not working - Pull from fields > attach doc from folder > send email
    By mikey386 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-07-2015, 03:42 PM
  6. [SOLVED] Attaching PDFs in a folder to an email.
    By yeahyeahyeah in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-02-2012, 06:02 PM
  7. Create Both Folder and Subfolders using Coloum A and B
    By IainB in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-25-2009, 09:03 AM

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