+ Reply to Thread
Results 1 to 10 of 10

Macro to move pdf files from folders and subfolders to another folder

  1. #1
    Forum Contributor
    Join Date
    10-14-2013
    Location
    INDIA
    MS-Off Ver
    EXCEL 2013
    Posts
    143

    Macro to move pdf files from folders and subfolders to another folder

    Hi

    With the following macro from the internet, I was able to move pdf files from a folder. But I am unable to move pdf files from the subfolders. Can anyone help me to resolve the same.

    Advance thanks.

    With regards

    buvanamali

    Please Login or Register  to view this content.

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

    Re: Macro to move pdf files from folders and subfolders to another folder

    .
    See if this works :

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    10-14-2013
    Location
    INDIA
    MS-Off Ver
    EXCEL 2013
    Posts
    143

    Re: Macro to move pdf files from folders and subfolders to another folder

    Dear Mr Logit

    I tried the above code. It loops through all the subfolders and copied around 455 files. But I wanted to move pdf files to the destination path.
    I just tried changing your code "Then File.Copy ToPath as Then File.Move ToPath", I got runtime error '58': File already exists. Then I checked the subfolders, it moved the files from the first subfolder only. Please help me in resolving the issue.
    Attached Images Attached Images
    Last edited by buvanamali; 07-20-2020 at 07:44 PM.

  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,015

    Re: Macro to move pdf files from folders and subfolders to another folder

    .
    This is untested here. See if it works for you.

    Please Login or Register  to view this content.
    Be aware the new added line will DELETE any PDF file you residing in the Folders and Subfolders ... AFTER the PDF file has been copied.
    Make certain you want those files deleted prior to running them macro.
    Last edited by Logit; 07-20-2020 at 08:36 PM.

  5. #5
    Forum Contributor
    Join Date
    10-14-2013
    Location
    INDIA
    MS-Off Ver
    EXCEL 2013
    Posts
    143

    Re: Macro to move pdf files from folders and subfolders to another folder

    Dear Mr Logit

    I tested the above code. It copied all the pdf files from all the sub folders but it deleted all other files in all the subfolders (like .docx, .xlsm etc) and emptied the folder.

    Please help me in resolving the issue.

    Thanks once again.

    buvanamali

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

    Re: Macro to move pdf files from folders and subfolders to another folder

    .
    Try this version :

    Please Login or Register  to view this content.
    Last edited by Logit; 07-20-2020 at 10:28 PM.

  7. #7
    Forum Contributor
    Join Date
    10-14-2013
    Location
    INDIA
    MS-Off Ver
    EXCEL 2013
    Posts
    143

    Re: Macro to move pdf files from folders and subfolders to another folder

    Dear Mr Logit

    Sorry for disturbing you. I had more than 1000 pdf files in a folder and subfolders. The above code was copying around 300 files from subfolders and throws an error message as per attachment. Please help me in resolving this issue.

    Once again thanks for your efforts.


    buvanamali
    Attached Images Attached Images

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

    Re: Macro to move pdf files from folders and subfolders to another folder

    .
    Look at post #6.

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

    Re: Macro to move pdf files from folders and subfolders to another folder

    .
    Here is another version :

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    10-14-2013
    Location
    INDIA
    MS-Off Ver
    EXCEL 2013
    Posts
    143

    Re: Macro to move pdf files from folders and subfolders to another folder

    Dear Mr Logit

    Thank you very much for your timely response. As advised, I will check up with few more folders and revert to you.
    In case if the error occurs I will come back to you with the nature of error.

    With regards

    buvanamali

+ 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. copy or cut pdf files from folders and subfolders into one single folder
    By druva in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-25-2019, 01:27 PM
  2. Move pdf files from multiple subfolders to a new folder
    By fabian_76 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2018, 04:57 PM
  3. [SOLVED] Macro to Copy and paste folders and subfolders without files in it
    By Madhut in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2016, 01:47 PM
  4. [SOLVED] Macro to move all files from one folder to multiple folders
    By mhbealey in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 12-23-2015, 08:35 PM
  5. Macro to Move Files from a Folder to Newly created folders based on value in a cell
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2015, 08:04 PM
  6. Create folders in all the subfolders and move subfolders
    By Amarjeet Singh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2015, 12:51 PM
  7. Needs macro to copy excel files from folders, subfolders to new folder
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2014, 08:53 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