PDA

View Full Version : [SOLVED] Resizing Excel Application



gibbo1715
01-27-2005, 01:42 AM
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

Jacob Hilderbrand
01-27-2005, 02:13 AM
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

gibbo1715
01-27-2005, 02:15 AM
many Thanks Jake

Jacob Hilderbrand
01-27-2005, 02:15 AM
You're Welcome :beerchug:

Take Care