Results 1 to 4 of 4

Thread: [RESOLVED] How to setup printing of dynamic tables?

  1. #1
    New Member
    Join Date
    Sep 12
    Posts
    2

    Resolved [RESOLVED] How to setup printing of dynamic tables?

    Hi guys,

    I have a problem that seems not to be exotic, however I couldn't find any solution via googles. I'm developing a universal macro to print reports from excel. Report need to be fit to one page wide by X pages tall (I use landskape orientation). Reports may have different number of rows and different number of columns as well. The problem is: how to find out how many pages a particular report will have? As sum of column's widht is a variable, the number of rows on each page is a variable too.

    I assumed that sum of columns width to sum of rows height would be a fixed ratio (from my calculation this would be about 1,330978261), however doing it this way didn't worked well.
    Do you have any ideas how to deal with it?

  2. #2
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,587

    Re: How to setup printing of dynamic tables?

    if you set it to fittopagewide it will adjust the number of pages by the scaled font size, so do you need to know how many pages?

    in my help file it specifies that this property only applies to the pagesetup property of worksheets (not ranges)
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    New Member
    Join Date
    Sep 12
    Posts
    2

    Re: How to setup printing of dynamic tables?

    Thanks for looking into this, Westconn1!

    Meanwhile I have eventually managed to find the solution!

    http://www.ozgrid.com/VBA/printed-pages.htm

    ...and this baby works!

    Also, when setting up printing by macro this may occur helpful:

    With ActiveSheet.PageSetup
    .FitToPagesWide = 1
    .FitToPagesTall = False - by this you let to print as many pages as need
    End With


  4. #4
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,587

    Re: How to setup printing of dynamic tables?

    it you do not set pages tall to any value, it would be false by default, which was what i was indicating above

    pls mark thread resolved
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •