Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detect Screen Resolution & Change View % (Excel 2002)

    Is it possible to detect a user's screen resolution and automatically open a sheet with a particular view %. For example, if screen resolution is 600x800, the workbook will adjust the view to 100, if it is 1024X768, it will open under 200% view.

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect Screen Resolution & Change View % (Excel 2002)

    Try this piece of code:

    <pre>Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    Public Const SM_CXSCREEN = 0
    Public Const SM_CYSCREEN = 1

    'Insert this code to your form:

    Private Sub test()
    Dim Tmp As String
    Tmp = GetSystemMetrics(SM_CXSCREEN) & _
    "x" & GetSystemMetrics(SM_CYSCREEN)
    MsgBox (Tmp)
    End Sub
    </pre>

    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Lounger
    Join Date
    Nov 2001
    Location
    Calgary, Alberta, Canada
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect Screen Resolution & Change View % (Excel 2002)

    I often change the view settings within my code. To do this I will select the range I want to be visible on screen and the set the Zoom property of ActiveWindow to True. This then adjusts the zoom % so that all of the selected range is visible on screen. This works fine for me as I mostly work in maximised windows, however, if this code is run in a Normal window it will adjust the zoom settings to suit the window size at that time, if you then maximise the window the zoom will not be at an optimum level.

    I have attached a simple example of how I would use this approach to resize the view for Height, Width and Range.

    Hope this helps,

  4. #4
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect Screen Resolution & Change View % (Excel 2002)

    Works great, thanks !

Posting Permissions

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