Results 1 to 5 of 5

Thread: [RESOLVED] Set The Scaling In Excel Spreadsheet

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Resolved [RESOLVED] Set The Scaling In Excel Spreadsheet

    In the Page Setup of an Excel Worksheet, there is a frame called "Scaling"

    There are two option buttons:

    1. Auto adjust to [number up/down control]% normal size
    2. Fit to: [number up/down control] page(s) wide by [number up/down control] tall.

    I need to know how to programmatically set Number two.

    Here is what I have. It does not generate any errors, but it also does not work.
    VB Code:
    1. bkWorkBook.Worksheets(1).PageSetup.FitToPagesWide = 1
    2.         bkWorkBook.Worksheets(1).PageSetup.FitToPagesTall = 1
    I also tried
    VB Code:
    1. shWorkSheet.PageSetup.FitToPagesWide = 1
    2.         shWorkSheet.PageSetup.FitToPagesTall = 1
    Again, this generated no errors, but also did not work.

    The following declarations apply
    VB Code:
    1. Private bkWorkBook As Workbook
    2. Private shWorkSheet As Worksheet

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Set The Scaling In Excel Spreadsheet

    Hack
    This is an easy one. These properties of the pagesetup object are ignored if the Zoom property is set to TRUE. You need to change that property to FALSE before you set these. Other than that, either synthax above is good. (I've been caught by this many times...)
    VB Code:
    1. With bkWorkBook.Worksheets(1).PageSetup
    2.     .Zoom = False
    3.     .FitToPagesWide = 1
    4.     .FitToPagesTall = 1
    5. End With
    Last edited by DKenny; May 8th, 2006 at 12:53 PM.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Set The Scaling In Excel Spreadsheet

    ZOOM Property??

    What the heck is the ZOOM property?

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: [RESOLVED] Set The Scaling In Excel Spreadsheet

    Zoom is the percentage value that the user can enter in the Auto adjust to [number up/down control]% normal size control on the Page Setup.
    If Excel sees any value in that property it will adjust the page size to that value. The only way to force it to use your FitToPage values is to set that property to FALSE.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [RESOLVED] Set The Scaling In Excel Spreadsheet

    Quote Originally Posted by DKenny
    Zoom is the percentage value that the user can enter in the Auto adjust to [number up/down control]% normal size control on the Page Setup.
    If Excel sees any value in that property it will adjust the page size to that value. The only way to force it to use your FitToPage values is to set that property to FALSE.
    VBA can be a humbling experience.

    Thanks again.

Posting Permissions

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



Click Here to Expand Forum to Full Width