Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window Size on Open - Excel

Status
Not open for further replies.

ADB1

Programmer
Aug 24, 2001
235
GB
Hi,

How do I specify and fix the size of a window in excel when the workbook/file is opened?

Many thanks.

A.
 
If you are ok with vba, try docmd.maximize

misscrf

It is never too late to become what you could have been ~ George Eliot
 



Hi,

What do mean by "fix?"

You can check the position & size properties of the Window object, (top, left, width, height).

You will not find docmd in Excel VBA.

However, you could turn on your macro recorder and record doing what you want, turn off the recorder and observe your recorded code.

Post back with your code if you need help.

Skip,

[glasses] [red][/red]
[tongue]
 
Put this code in "ThisWorkbook."

Code:
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Private Const SM_CXSCREEN = 0   'Screen width
Private Const SM_CYSCREEN = 1   'Screen height

Private Sub Workbook_Open()
   Application.WindowState = xlNormal
   Application.Height = Get_Screen_Height
   Application.Width = Get_Screen_Width
   Application.Top = 0
   Application.Left = 0
End Sub

Public Function Get_Screen_Width() As Long
   Get_Screen_Width = GetSystemMetrics(SM_CXSCREEN)
End Function

Public Function Get_Screen_Height() As Long
   Get_Screen_Height = GetSystemMetrics(SM_CYSCREEN)
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top