+ Reply to Thread
Results 1 to 6 of 6

Page setup zoom false to true

Hybrid View

  1. #1
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Page setup zoom false to true

    I want to set fit to one page first then to change to a specific zoom (e.g. 50%) if it's less than that after the fittoonepage. However it gives me an error when I tried to flip the zoom from false to true:

    with sheet1.pagesetup
    .zoom=false 
    .fittopagestall=1
    .fittopageswide=1
    
    .zoom=true
    if .zoom<50 then
       .zoom=50
       .fittopageswide=1
    end if
    end with
    I got a runtime error 1004 of unable to set the zoom property. Many thanks!

    April

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Page setup zoom false to true

    Answer deleted by LJMetzger. Was the correct answer to the wrong question.
    Last edited by LJMetzger; 01-03-2016 at 10:41 AM. Reason: Deleted correct answer to wrong question.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Page setup zoom false to true

    Zoom is a property of the PageSetup object, but it has to be a number (percentage)

    change that line to
    .Zoom = 100
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Page setup zoom false to true

    Quote Originally Posted by mikerickson View Post
    Zoom is a property of the PageSetup object, but it has to be a number (percentage)

    change that line to
    .Zoom = 100
    Thanks for the reply! If I change .zoom=true to 100, however, the if (.zoom<50) condition will never be met? Also I think zoom doesn't have to be a number as it has no problem passing the zoom=false line. I googled and I found some threads about that's the way you actually can set the pagesetup to fittoonepage?
    Last edited by aprildu; 01-03-2016 at 11:26 PM.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Page setup zoom false to true

    Quote Originally Posted by aprildu View Post
    ...I googled and I found some threads about that's the way you actually can set the pagesetup to fittoonepage?
    The ObjectBrowser shows that .FitToPagesWide and .FitToPagesTall as properties of the PageSetup object.

    https://msdn.microsoft.com/en-us/lib.../ff194365.aspx
    https://msdn.microsoft.com/EN-US/lib.../ff194582.aspx

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Page setup zoom false to true

    aprildu said: it gives me an error when I tried to flip the zoom from false to true
    In Excel VBA, False (numerical value 0) and True (numerical value -1) are really numbers masquerading as booleans. When you set the value to True, the negative number probably is the reason for the error, since a negative zoom does not make any sense in this space time continuum.

    When you set the value to False (0) that is probably why the 'Fit to Page' works.

    The following thread discusses the same topic and may help you: http://www.mrexcel.com/forum/excel-q...-property.html

    Lewis

+ 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. What is best to use for helper cells 0 or 1, typed true or false or =true =false
    By Gingermuppet in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2014, 10:41 PM
  2. [SOLVED] in this TRUE OR FALSE function, i want desired name instead of display true or false
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-15-2013, 06:44 PM
  3. [SOLVED] need help with page setup/print Setup on a worksheet
    By laurabach in forum Excel General
    Replies: 9
    Last Post: 04-28-2013, 11:44 PM
  4. [SOLVED] Search for 2 true arguments and return true or false
    By David in forum Excel General
    Replies: 3
    Last Post: 07-15-2006, 05:20 AM
  5. Print setup - fit to page - zoom
    By Zurn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-08-2006, 06:51 AM
  6. [SOLVED] Function to return True/False if all are validated as True by ISNU
    By Tetsuya Oguma in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-15-2006, 06:30 AM
  7. [SOLVED] Reverse false and combine with true true value
    By Emmie99 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  8. [SOLVED] Calculate page setup zoom value for 1 to 1 printing
    By mgill in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-09-2005, 05: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