Window Position & Size

  • Thread starter Thread starter socialism001
  • Start date Start date
S

socialism001

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
 
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
 
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
 
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
 

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

Back
Top