+ Reply to Thread
Results 1 to 27 of 27

Scan subfolders for PDF files and count pages

  1. #1
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Scan subfolders for PDF files and count pages

    Dear Friends,

    I found this code for scanning of folder for PDF files, counting number of pages and exporting of result to worksheet.


    Please Login or Register  to view this content.
    I found that this code does not find the PDF files that stored in subfolders. Also I need to define needed path via "Dialog window".

    Please help me to solve this problem, because this macro is very necessary for my work.

    Thanks and have a nice day

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Scan subfolders for PDF files and count pages

    Give this a try in a new module:

    Please Login or Register  to view this content.
    WBD
    Last edited by WideBoyDixon; 10-03-2018 at 05:30 AM.
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Re: Scan subfolders for PDF files and count pages

    WOW, It's works!!!! Thank you. Last question: could you please include in code, that this list will be created in new sheet with name "PDF_List"?

  4. #4
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Scan subfolders for PDF files and count pages

    Please Login or Register  to view this content.
    WBD

  5. #5
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Re: Scan subfolders for PDF files and count pages

    It's works...Sorry last addition from my side: how I can change filepath to file name without *.pdf ? Thank you

  6. #6
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Scan subfolders for PDF files and count pages

    Change this line:

    Please Login or Register  to view this content.
    WBD

  7. #7
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Re: Scan subfolders for PDF files and count pages

    Dear WBD, it is the same result. In column A I receive full path C:\Users\xxxx\Desktop\xxx\xxx.pdf

    But i need only xxx.pdf

    How i can proceed in this case? Thx

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Scan subfolders for PDF files and count pages

    @WBD
    Thanks a lot for the code
    I have tested it and found incorrect results in the number of the PDF pages count
    Example I have a PDF with 17 pages and the result was 21 .. Any idea why?
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  9. #9
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Scan subfolders for PDF files and count pages

    Please Login or Register  to view this content.
    WBD

  10. #10
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Scan subfolders for PDF files and count pages

    Quote Originally Posted by YasserKhalil View Post
    @WBD
    Thanks a lot for the code
    I have tested it and found incorrect results in the number of the PDF pages count
    Example I have a PDF with 17 pages and the result was 21 .. Any idea why?
    There's no reliable method to count pages in a PDF file. The method used above is to find the number of times the "\Page" occurs in the file as this usually signifies a new page. If you open up the PDF in a text editor, you can search for "\Page" yourself (excluding "\Pages") to see how many times that occurs.

    WBD

  11. #11
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Scan subfolders for PDF files and count pages

    But using acrobat pro gives correct number of pages
    Please Login or Register  to view this content.

  12. #12
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Scan subfolders for PDF files and count pages

    Great! Then use that. If the OP is happy to spend £160 on some software, it's a great solution.

    WBD

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Scan subfolders for PDF files and count pages

    The post just in case the OP has already the acrobat Pro and absolutely won't buy for that task !!

  14. #14
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Re: Scan subfolders for PDF files and count pages

    Awesome, WBD! It is works Shake your hand

  15. #15
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Re: Scan subfolders for PDF files and count pages

    Quote Originally Posted by YasserKhalil View Post
    @WBD
    Thanks a lot for the code
    I have tested it and found incorrect results in the number of the PDF pages count
    Example I have a PDF with 17 pages and the result was 21 .. Any idea why?
    I have the same issue, when in one document you have A4 and A3 pages. The same story for A0 and A1 format. Anyway WBD helps me very much.

  16. #16
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Scan subfolders for PDF files and count pages

    Great. Glad it worked for you and thanks a lot for WBD for his great solution

  17. #17
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Scan subfolders for PDF files and count pages

    Just one more thing on this. I did find this library:

    https://www.debenu.com/products/deve...ary-lite/free/

    Using this, I managed to create an implementation of a page count function that works reliably. If anyone's interested.

    WBD

  18. #18
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Scan subfolders for PDF files and count pages

    That's great WBD. I will appreciate if you share it

  19. #19
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Scan subfolders for PDF files and count pages

    The the library installed and registered:

    Please Login or Register  to view this content.
    WBD
    Last edited by WideBoyDixon; 10-04-2018 at 08:56 AM.

  20. #20
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Scan subfolders for PDF files and count pages

    When trying to download I have entered my email but I got this message
    Please enter your business email address. This form does not accept addresses from gmail.com.

    And I have no business email address !!

  21. #21
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Scan subfolders for PDF files and count pages


  22. #22
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Scan subfolders for PDF files and count pages

    Thank you very much

    After installing it I have searched Reference for Debenu but didn't find so I tried to browse the dll file
    But I don't know which one is the correct dll
    Untitled.png

  23. #23
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Scan subfolders for PDF files and count pages

    Read the GettingStarted.pdf that resides in the installation folder. It tells you how to register the DLL. If you're using 32-bit Office, register the 32-bit DLL. If you're running 64-bit Office then register the 64-bit DLL. Or try both.

    WBD

  24. #24
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Scan subfolders for PDF files and count pages

    Thanks a lot for guiding me
    Now I have registered it and it appears in References and also I have tested that code to make sure everything is OK
    Please Login or Register  to view this content.
    But when testing your last code I got the worksheet PDF_List but empty with no results .. Any idea?

  25. #25
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Scan subfolders for PDF files and count pages

    After debugging the code I have found this missing line
    Please Login or Register  to view this content.
    Now it is perfect

    Thanks a lot for sharing your awesome solution WBD

  26. #26
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Scan subfolders for PDF files and count pages

    Quote Originally Posted by YasserKhalil View Post
    But using acrobat pro gives correct number of pages
    Please Login or Register  to view this content.
    hi Yasser,
    request you post full code here and also tell me which reference should i apply from tools menu.

  27. #27
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Scan subfolders for PDF files and count pages

    You have to install Acrobat Pro (it is not free)
    And from References you have to select "Acrobat"

+ 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] list of subfolders in folder - without files and sub-subfolders
    By MartyZ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2022, 10:56 AM
  2. [SOLVED] Count Files in a folder and subfolders, with specific name
    By Un-Do Re-Do in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-24-2018, 01:14 AM
  3. Excel VBA to scan a PDF for keyword and extract PDF Pages to single PDF File
    By Brawnystaff in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2014, 02:00 AM
  4. [SOLVED] Files within Multiple SubFolders and SubFolders Within It
    By codeslizer in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-18-2013, 04:18 AM
  5. copy files from subfolders
    By tryer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-08-2012, 05:53 PM
  6. Scan Through All Files and Subdirectories
    By jasoncw in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-06-2009, 11:58 AM
  7. [SOLVED] copy subfolders, replace text in files and save files in copied subfolders
    By pieros in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-01-2005, 09:05 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