Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel Zoom Property

Posted on 2002-07-02
8
Medium Priority
?
770 Views
Last Modified: 2008-03-17
I use Excel 2000 via automation from a VB application.

After setting FitToPagesWide (to 1) and FitToPagesTall (to False), I need to retreive the numerical value of the Zoom property (just like we can see it into the page preview setup in Excel).
0
Comment
Question by:Éric Moreau
  • 3
  • 3
  • 2
8 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 7125516
Hi emoreau,

you can try

'writing
Worksheets("Sheet1").PageSetup.Zoom = 150
'reading
MsgBox Worksheets("Sheet1").PageSetup.Zoom

HAGD:O)Bruintje
0
 
LVL 70

Author Comment

by:Éric Moreau
ID: 7125632
No. I need to set the FitToPagesWide property and retreive the Zoom value.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7125865
that's funny, seems to be not available through the print preview but only through page setup tho both come up with the same dialogs

maybe someone else has an idea
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Expert Comment

by:pierrecampe
ID: 7128284
dont know if this is of any help,it probably is a terrible kludge,but maybe it will bring you to some ideas
i made the following macro in word:
Sub Doit()
    Dim a
    Dim b
    Dim c
    With Application.ActiveSheet.PageSetup
        a = .FitToPagesWide
        b = .FitToPagesTall
        .FitToPagesWide = False
        .FitToPagesTall = False
    End With
    With Application.Dialogs(xlDialogPageSetup)
        .Show
        .Show
    End With
    c = Application.ActiveSheet.PageSetup.Zoom
    With Application.ActiveSheet.PageSetup
        .FitToPagesWide = a
        .FitToPagesTall = b
        .Zoom = False
    End With
    MsgBox c
End Sub

this will let you know the zoom without changing anything
problem is that it still requeres user intervention to press the ok button,because the dialog seems to be a modal window
but maybe if before the .show you start another program
that continualy searches for the pagesetup window and when it finds it sends an enter to it, it may work


0
 
LVL 70

Author Comment

by:Éric Moreau
ID: 7129776
As soon as the settings are set to FitToPage, the Zoom property is containing False (instead of the numerical value).
0
 
LVL 6

Accepted Solution

by:
pierrecampe earned 800 total points
ID: 7130337
ok so here a vb program ( or 2) that does what you asked
i know it is a kludge, and may not suit your needs, but it does what you asked
program1:
Dim objExcel As Excel.Application
Private Sub Command1_Click()
    Dim a
    Dim b
    Dim c
    Set objExcel = New Excel.Application
    objExcel.Visible = True
    objExcel.Workbooks.Add
    For i = 65 To 85
        ab$ = Chr(i) & i - 64
        objExcel.Range(ab$).Select
        objExcel.ActiveCell.FormulaR1C1 = Chr(i)
    Next
    With objExcel.ActiveSheet.PageSetup
       .Zoom = False
       .FitToPagesWide = 1
       .FitToPagesTall = 1
       a = .FitToPagesWide
       b = .FitToPagesTall
    End With
   
    Shell "C:\0Test\1\Projtimer.exe 4"

    With objExcel.Dialogs(xlDialogPageSetup)
         .Show
         .Show
         With objExcel.ActiveSheet.PageSetup
             .FitToPagesWide = False
             .FitToPagesTall = False
         End With
         .Show
         .Show
    End With
    With objExcel.ActiveSheet.PageSetup
       c = .Zoom
       .FitToPagesWide = a
       .FitToPagesTall = b
       .Zoom = False
   End With
    MsgBox "The Zoom At This Moment Is " & c & " And The FitToPagesWide Is " & a
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set objExcel = Nothing
End Sub

program2:( this program is named 'Projtimer.exe')

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim Cmmnd As Integer
Dim Number As Integer

Private Sub Form_Load()
    Me.Visible = False
    Timer1.Interval = 1000
    Cmmnd = Command
End Sub

Private Sub Timer1_Timer()
    'Beep
    Dim WinWnd As Long
    WinWnd = FindWindow(vbNullString, "Page Setup")
    If WinWnd Then
       SendKeys "{ENTER}", True
       Number = Number + 1
    End If
    If Number = Cmmnd Then
       Unload Me
    End If
End Sub
0
 
LVL 70

Author Comment

by:Éric Moreau
ID: 7130436
It is not "elegant" but it is doing the job.
0
 
LVL 6

Expert Comment

by:pierrecampe
ID: 7130614
i know it's a kludge
but thanks for the points
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question