+ Reply to Thread
Results 1 to 21 of 21

Extract Page count of pdf in macro

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

    Extract Page count of pdf in macro

    Hello Friends,

    i have multiple pdf files and want to extract the pages count of each individual pdf.

    is it possible in macro?

    Please suggest me

    i want 2 details of each file
    i.e. 1) FileName, 2) Pages

  2. #2
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Extract Page count of pdf in macro

    Hi Mohan,

    check out this attached file and let me know is it for your looking for
    Attached Files Attached Files
    Thanks - Naveed
    -----------------------------
    If the suggestion helps you, then Click * to Add Reputation
    To Attach File: Go Advanced>>Manage Attachments>>Add Files (In Top Right Corner)>>SelectFiles>>.........Locate Your File(s)>>Upload Files>>Done (In Bottom Right)
    1. Use [code] code tags [\code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

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

    Re: Extract Page count of pdf in macro

    Hello Naveed,

    thanks for reply

    i run your code and found this error
    Please Login or Register  to view this content.
    also fileName on sheet1 is ok but page count of each file is 0 which wrong

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

    Re: Extract Page count of pdf in macro

    Hello Naveed,

    thanks for reply

    i run your code and found this error
    Please Login or Register  to view this content.
    also fileName on sheet1 is ok but page count of each file is 0 which wrong

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

    Re: Extract Page count of pdf in macro

    Hello Naveed,

    thanks for reply

    i run your code and found this error
    Please Login or Register  to view this content.
    also fileName on sheet1 is ok but page count of each file is 0 which wrong

  6. #6
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Extract Page count of pdf in macro

    Hi mohan

    replace below code

    Please Login or Register  to view this content.

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

    Re: Extract Page count of pdf in macro

    Hello Naveed,

    now the last line of pageCount function having problem

    run-time error no. 13
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Extract Page count of pdf in macro

    The code below works for me and correctly puts the file name in column A with pages in column B
    I have tried it with Excel2010 and Excel2016 and BOTH work
    I am also using Windows7
    Try my file attached - amend the folder path, then run PDFandNumPages


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kev_; 06-10-2017 at 10:35 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

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

    Re: Extract Page count of pdf in macro

    Thanks for reply
    i tried your code but this time i get all filename in column A but in B Column Pagecount shows 0.

    where i am getting wrong, please suggest

  10. #10
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Extract Page count of pdf in macro

    How do you expect me to work that out when you provide no information?

    Please post your modified code enclosed in code tags

    thanks

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

    Re: Extract Page count of pdf in macro

    Hi,

    i just make one changes in your code i.e Path
    rest of all the code is same for me.

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

    Re: Extract Page count of pdf in macro

    Hi Kev,

    i am using Acrobat reader 9.0 version of pdf

  13. #13
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Extract Page count of pdf in macro

    Please post your code as requested

    Also attach an example pdf file

    thanks

    (the code works for me with all pdf's on my computer, but your pdf file may have a different structure???)
    Last edited by kev_; 07-04-2017 at 06:48 AM.

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

    Re: Extract Page count of pdf in macro

    Hi Kev,

    I have no code if you see my first post.
    i required two 2 things from pdf file i.e. File Name and Pages
    as per your code i get only file name correctly but page count shows 0.
    i check your code on another PC where Acrobat professional 7.0 version installed and found OK.
    thats why i made last post that "i am using Acrobat Reader 9.0 version of pdf."
    now we know that its a pdf version problem so is there any chance to get page count in Acrobat reader version?

    Please suggest.

  15. #15
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Extract Page count of pdf in macro

    Please attach 2 pdf files for me to test
    - pdf(1) = where page count = 0
    - pdf(2) = where page count > 0

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

    Re: Extract Page count of pdf in macro

    Hi Kev,

    there is no problem in pdf, the problem is in version.
    if you have Adobe Reader 9.0 version of pdf then you can also check

  17. #17
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Extract Page count of pdf in macro

    Try modifying the code. Please add one line of code after this line:
    Please Login or Register  to view this content.
    add this line:
    Please Login or Register  to view this content.
    Does the message pop up when you run the code on the "bad" machine?

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

    Re: Extract Page count of pdf in macro

    Hi KEV,

    yes,
    i got the msg "Overflow tripped"

  19. #19
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Extract Page count of pdf in macro

    I have amended the macro to provide me with extra information on sheet named "sInput" in attached workbook

    Please:
    1 amend this line in the macro to match a folder on your system
    Please Login or Register  to view this content.
    2 Put 10 pdf files in that folder

    3 run the macro

    4 manually enter the number of pages against each file in column B on sheet FileList

    5 attach the workbook to your reply

    thanks
    Attached Files Attached Files
    Last edited by kev_; 07-05-2017 at 05:23 AM.

  20. #20
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Extract Page count of pdf in macro

    post deleted by kev_
    Last edited by kev_; 07-05-2017 at 05:23 AM.

  21. #21
    Registered User
    Join Date
    04-13-2018
    Location
    Pakistan
    MS-Off Ver
    2013
    Posts
    3

    Re: Extract Page count of pdf in macro

    AOA Naveed,

    found the error "Run-time error '75': while running the macro with your shared excel file.

+ 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. I am looing for a macro to extract the title of a web page from a URL
    By emymeeky in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-28-2015, 04:32 PM
  2. [SOLVED] Extract and count data - macro
    By missy22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-16-2014, 07:07 AM
  3. Automatically adding a blank page at the end of sheets with page count odd
    By NewDawn999 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-15-2013, 02:33 PM
  4. Extract Data from a Web Page - using VBA
    By Tejas.T in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-21-2012, 03:17 PM
  5. Extract only numbers from one cell to another page?
    By sixout in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-16-2012, 12:13 PM
  6. Replies: 2
    Last Post: 08-04-2011, 06:42 AM
  7. [SOLVED] Inserting page number & page count in cells
    By Jeff in forum Excel General
    Replies: 0
    Last Post: 05-02-2005, 04:06 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