Consulting

Results 1 to 4 of 4

Thread: Resizing Excel Application

  1. #1
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location

    Resizing Excel Application

    Morning

    Ok I know how to hide excel completely when using a userform but because my users may open other excel spreadsheets this is problamatic, is it possible to resize excel using VBA so when the userform is opened excel is always in the center of the screen?

    I know this can be done using the code below but my users have different screen resolutions

    Application.WindowState = xlNormal 
    Application.Width = 213.75
    Application.Height = 165.75
    Application.Left = 184
    Application.Top = 133.75
    So was wondering how to ensure it is always in the center of the screen regardless of my users screen resolution?

    Thanks in advance

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    This macro will make Excel half of its maximized size and center it on the screen.


    Option Explicit
     
    Sub ResizeExcel()
    Dim x               As Double
    Dim y               As Double
    Dim TempExcelApp    As New Excel.Application
    TempExcelApp.WindowState = xlMaximized
        x = TempExcelApp.Width
        y = TempExcelApp.Height
        TempExcelApp.Quit
        Application.WindowState = xlNormal
        Application.Width = x / 2
        Application.Height = y / 2
        Application.Left = (x - (x / 2)) / 2
        Application.Top = (y - (y / 2)) / 2
    End Sub

  3. #3
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    many Thanks Jake

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

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