Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resize and position excel window
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resize and position excel window
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 "macroapa" wrote: 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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resize and position excel window
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resize and position excel window
On 22 Oct, 10:36, Incidental wrote:
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel: Expose whole window or at least top resize handles. | Excel Discussion (Misc queries) | |||
Insert, position, and resize a picture w/ Macro | Excel Discussion (Misc queries) | |||
unable to get the excel app event trigger for for window resize | Excel Programming | |||
Window Resize | Excel Programming | |||
Window Resize | Excel Programming |