Resize and position excel window

M

macroapa

Hi,

I am trying to write some vba code that when run will resize the Excel
window and repostition the window (to the top right of the screen).

I have found simliar code that works for MSAccess, but I'm struggling
to re-write it for excel.

Any help appreciated.

Thanks.
 
M

Mike H

Hi,

Try this in a general module and adjust the numbers to get what you want

Sub resize()
With Application
.WindowState = xlNormal
.Left = 450
.Top = 1
.Width = 500
.Height = 500
End With
End Sub

Mike
 
M

macroapa

Hi Macroapa

The code below should do what you want, it will set the width and
height to 75% of the full screen size but you can change this to an %
you want.

Option Explicit
Dim oldHeight, oldWidth As Long
Dim newHeight, newWidth As Long

Private Sub CommandButton1_Click()

    With Application

        oldHeight = .Height
        oldWidth = .Width

        newHeight = oldHeight / 100 * 75
        newWidth = oldWidth / 100 * 75

        .WindowState = xlNormal

        .Height = newHeight
        .Width = newWidth

        .Top = 0
        .Left = oldWidth - newWidth - 3

    End With

Hope this helps

Steve

thanks both, that's great.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top