ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Window Position & Size (https://www.excelbanter.com/excel-discussion-misc-queries/25977-window-position-size.html)

[email protected]

Window Position & Size
 
Is there a way in Excel 2000 that when I open a file that it will
resize and position the excel application in the top 1/2 of the screen
? then I can have my browser in the lower 1/2 of the screen where I get
my data from.

Thanks,
Chris


Dave Peterson

How about something like:

Option Explicit
Private Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long

Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1
Sub auto_open()
Dim myWidth As Long
Dim myHeight As Long

'with tools|references|microsoft internet controls unchecked
Dim MSIEApp As Object
Set MSIEApp = CreateObject("InternetExplorer.Application")

'with tools|references|microsoft internet controls checked
'Dim MSIEApp As InternetExplorer
'Set MSIEApp = New InternetExplorer

With Application
.WindowState = xlMaximized
myWidth = .Width
myHeight = .Height
.WindowState = xlNormal
.Left = 0
.Width = myWidth
.Top = myHeight / 2
.Height = myHeight / 2
End With


With MSIEApp.Application
.Visible = True
.Top = 0
.Left = 0
.Height = GetSystemMetrics(SM_CYSCREEN) / 2
.Width = GetSystemMetrics(SM_CXSCREEN)
End With
End Sub


If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm



wrote:

Is there a way in Excel 2000 that when I open a file that it will
resize and position the excel application in the top 1/2 of the screen
? then I can have my browser in the lower 1/2 of the screen where I get
my data from.

Thanks,
Chris


--

Dave Peterson

[email protected]

That works :) Is there a way to have the excel sheet stay at the top of
the screen instead of resizing at the bottom.

Thanks for your help,
Chris


Dave Peterson

Oops. I forgot the original question when I was setting it up.

Option Explicit
Private Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1
Sub auto_open()
Dim myWidth As Long
Dim myHeight As Long

'with tools|references|microsoft internet controls unchecked
Dim MSIEApp As Object
Set MSIEApp = CreateObject("InternetExplorer.Application")

'with tools|references|microsoft internet controls checked
'Dim MSIEApp As InternetExplorer
'Set MSIEApp = New InternetExplorer

With Application
.WindowState = xlMaximized
myWidth = .Width
myHeight = .Height
.WindowState = xlNormal
.Left = 0
.Width = myWidth
.Top = 0
.Height = myHeight / 2
End With

With MSIEApp.Application
.Visible = True
.Height = GetSystemMetrics(SM_CYSCREEN) / 2
.Width = GetSystemMetrics(SM_CXSCREEN)
.Top = .Height
.Left = 0
End With
End Sub



wrote:

That works :) Is there a way to have the excel sheet stay at the top of
the screen instead of resizing at the bottom.

Thanks for your help,
Chris


--

Dave Peterson

[email protected]

Thanks for your help,
Chris



All times are GMT +1. The time now is 10:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com