I'm trying to use this code near the start of a macro to set the size and position of the Excel window in pixels.
Sub TestSizePosition()
'Size/Position Tracksheet
Application.WindowState = xlNormal
Application.Left = 200
Application.Top = 1
Application.Width = 800
Application.Height = 800
'But the results are very different to the values set
End Sub
As you see below, the actual results from a few tests bear little relation to the settings.
---------- SET --------- -------- ACTUAL ---------
Left,Top Width x Height Left,Top Width x Height
======== ============= ======== ==============
0,0 1000 x 1000 -2,-2 1333 x 1208
2,2 1500 x 1080 1,1 1928 x 1208
1,1 1800 x 1000 0,0 1928 x 1208
1,1 1600 x 1000 0,0 1928 x 1208
1,1 1200 x 1000 0,0 1600 x 1208
1,1 900 x 960 0,0 1200 x 1208
1,1 800 x 500 0,0 1066 x 666
200,1 800 x 800 265,0 1066 x 666
What is going wrong and how can I get an accurate result please?
I've attached an example of the workbooks I want to size.
EDIT: A short time after posting I found a page which implies the actual values are roughly 3/4 of the Settings. So are there no commands for generating exact pixel sizes and positions?
Bookmarks