Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Get zoom value on pagesetup (VB 6.0)

    Hi,

    I'm trying to write a VB program. I am controlling an Excel object and after i fit the columns to one page in the pagesetup, i want to save the Zoom value in a variable. For instance if it will fit on one page as 86% then i want to save the 86. I don't know how to get to the 86 in VB 6.

    i have myXl as excel
    myBook as workbook
    mySheet as activesheet

    I've tried many variations but can't figure out it out. I've tried something like...

    x = MyXl.MyBook.PageSetup.Zoom.Value

    Any help is greatly appreciated. Thank you.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Get zoom value on pagesetup (VB 6.0)

    When you specify "Fit to 1 page(s) wide by 1 tall", Zoom is set to False, for the zoom percentage is calculated dynamically each time the worksheet is printed. If you would store the zoom percentage, it might not be valid next time.

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Get zoom value on pagesetup (VB 6.0)

    yes, but once i've determined the proper zoom then i want to put in pgbreaks myself and then change the zoom to what it was before. That's why i have to save it first.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Get zoom value on pagesetup (VB 6.0)

    I found some code in the newsgroups that inspired the attached rather tricky code; it uses SendKeys and is language-dependent. (It messed up the display of the post, so I have attached it in a text file.)

    Perhaps you can adapt it to your needs.

  5. #5
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get zoom value on pagesetup (VB 6.0)

    If you're looking to set up code that will, say, adjust the size of the page to print only one page horizontally and then control the vertical page breaks, you could try something like this:<pre>Sub PrintRange()
    On Error Resume Next
    With ActiveSheet
    ActiveWindow.View = xlPageBreakPreview
    .VPageBreaks(1).DragOff xlToRight, 1
    Set .HPageBreaks(1).Location = Range("A70")
    Set .HPageBreaks(2).Location = Range("A95")
    .PageSetup.PrintArea = "$A$5:$K$146"
    .PageSetup.Orientation = xlLandscape
    .UsedRange.Style = "Comma [0]"
    .PageSetup.PrintTitleRows = "$1:$4"
    .PageSetup.PrintTitleColumns = ""
    ActiveWindow.View = xlNormalView
    End With
    End Sub</pre>

    HTH
    Gre

Posting Permissions

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