+ Reply to Thread
Results 1 to 20 of 20

Excel pdf page numbers

  1. #1
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Excel pdf page numbers

    Hi,

    I am using VBA to save all sheets on the workbook to a pdf file.

    Please Login or Register  to view this content.
    How can i count the number of pages on the pdf file ?
    If you think someone helped you, click on the "* Add Reputation" as a way to say thank you.

    If your problem is solved, go to Thread Tools and select Mark This Thread Solved

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: Excel pdf page numbers

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,134

    Re: Excel pdf page numbers

    Alternative;

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Re: Excel pdf page numbers

    Thanks porucha vevrku / Haluk.

    However, both the options seems to give only the number / count of the sheets selected.

    I was after the total number of pages in the pdf file (which would be sum of page number of individual sheets selected.)

    For the attached, pdf file will have six pages but the vba code will return value of 3 for each of the cases which is the number of sheets selected.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,134

    Re: Excel pdf page numbers

    Then, you will probably need another procedure or function to get the count of pages of the created file....

    Is this going to be OK for you?

  6. #6
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: Excel pdf page numbers

    Quote Originally Posted by saravnepali View Post
    ...For the attached ...
    When I try to open your file, I get a message that some data is corrupted in it.
    If you have any unusual, stacked data grouping in it (for example), try to remove it before uploading the file to the forum.

  7. #7
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Re: Excel pdf page numbers

    Haluk,

    ANother procedure / function is fine if it works.

    porucha vevrku Attached file again, hope it works. This has 8 pages on a pdf file.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    Re: Excel pdf page numbers

    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: Excel pdf page numbers

    I also tried this method, but the results are inconclusive/unclear/ambiguous (?), sometimes there are 11 and sometimes 12 pages (the last page is blank).
    Also with
    Please Login or Register  to view this content.
    as Haluk suggested.

    A 'pdf' printout is always 12 pages long => saravnepali has 8 pages -> "This has 8 pages on a pdf file"
    I didn't change anything in the xls file => it seems the "pdf printer" has "different settings".

    ???

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    Re: Excel pdf page numbers

    @ porucha vevrku
    Re: "but the results are inconclusive/unclear/ambiguous (?)"
    Not if you set the print areas in each sheet.

  11. #11
    Valued Forum Contributor
    Join Date
    12-22-2015
    Location
    HK
    MS-Off Ver
    2010
    Posts
    532

    Re: Excel pdf page numbers

    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Re: Excel pdf page numbers

    I tried the option by jolivanes for different files and it works good.

    Thanks.

  13. #13
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,134

    Re: Excel pdf page numbers

    Quote Originally Posted by saravnepali View Post
    Haluk,

    ANother procedure / function is fine if it works.

    You may try this, which was written a long time ago;

    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: Excel pdf page numbers

    Quote Originally Posted by jolivanes View Post
    ... set the print areas in each sheet ...
    Ok, but it does not change the fact that it is actually done in the wrong place, these our trials/attempts.
    From what I can see, the correct solution will be the Haluk's code, which checks the number of pages in an already created 'pdf' document.

  15. #15
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    Re: Excel pdf page numbers

    If you think that if you're going to print 6 pages and you would miraculously end up with a different amount, I would say, yes, go for it.
    Maybe ask saravnepali if he just wants to know the amount of pages or if he indeed only want to count them after like you suggest.

  16. #16
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: Excel pdf page numbers

    jolivanes, don't take it "personally", I was only wondering about this in the context of the question saravnepali from post #1:
    Quote Originally Posted by saravnepali View Post
    ... How can i count the number of pages on the pdf file ?

  17. #17
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,134

    Re: Excel pdf page numbers

    @jolivanes ;

    I guess porucha vevrku means to say that; if you don't design (or forget to do do) the page setup of the Excel sheets before exporting as an PDF file, it would be an option, to get the count of pages of the created PDF file by another function.

    So, let's leave the stage to the OP ...
    Last edited by Haluk; 11-27-2020 at 04:00 PM.

  18. #18
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    Re: Excel pdf page numbers

    @ porucha vevrku & @ Haluk
    No offence at all. I think we all see people asking for a solution and they more or less supply us with what they they think should happen.
    Most people that help on these forums have their own way of doing things, "All roads lead to Rome" comes to mind, so I think we should read between the lines and give a solution to what we think is needed.
    If you find I was too abrupt in Post #15, just let me know. As the years progress on you, you tend to get that way. Another saying for that could be "Been there, done that and have the T-Shirt to prove it.
    Anyway, keep up the good work you guys and I will try to do the same my way!!!
    Hopefully we can needle each other in a positive way every so once in a while. Life at the moment is boring enough with all the restrictions we have to adhere to.

  19. #19
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: Excel pdf page numbers

    Ok,

    Quote Originally Posted by jolivanes View Post
    Life at the moment is boring enough with all the restrictions we have to adhere to

    I would call it different, if the forum rules didn't forbid this, I would say that life at the moment is highly shitty, but I don't know how the moderators would react to that, so better not to say it.
    Last edited by mjr veverka; 11-27-2020 at 05:00 PM.

  20. #20
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,134

    Re: Excel pdf page numbers

    jolivanes, no problem .... good luck to all of us.

    And, porucha vevrku .... I agree with you.
    Last edited by Haluk; 11-27-2020 at 05:05 PM.

+ 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. Replies: 2
    Last Post: 10-14-2020, 09:08 PM
  2. Using Section Page Numbers and Document Page Numbers In Footer
    By janschepens in forum Word Formatting & General
    Replies: 2
    Last Post: 03-16-2012, 01:54 PM
  3. How do I put page numbers as watermarks in Excel
    By Bill in forum Excel General
    Replies: 1
    Last Post: 02-21-2006, 10:45 AM
  4. [SOLVED] Excel page numbers
    By hanadiv in forum Excel General
    Replies: 1
    Last Post: 11-21-2005, 11:15 AM
  5. How to Add page numbers to a excel spreadsheet?
    By redhead101863 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-22-2005, 08:05 PM
  6. [SOLVED] Page Numbers in Excel
    By Terri D. in forum Excel General
    Replies: 3
    Last Post: 06-28-2005, 03:05 PM
  7. excel page numbers
    By Steve J. Vaughan in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-05-2005, 05:06 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