Excel opens Maximized, but Workbook opens minimized in Excel Scre.

G

Guest

When I open Excel, the application opens Maximized. But when I open a
Workbook while in Excel or Start / Documents / *.xls, the Workbook opens
minimized within the application. How can I fix it so that all workbooks open
maximized?

Thanks
 
D

Dave Peterson

Excel likes to help by remembering how you closed the workbook in conjunction
with the current window state.

If you always use maximized windows and save all your workbooks that way, I
think you'll be ok.

But as soon as you deviate (or open a workbook that's less than maximized,
you'll be maximizing the window again).

Alternatively, you could use an application event that always maximizes all the
windows when you open any workbook.

If you want to try that:

create a new workbook.
Hit alt-f11 to get to the VBE
hit ctrl-r to see the project explorer (like windows explorer)
expand your project to see the ThisWorkbook module.
paste this code in:

Option Explicit
Public WithEvents xlApp As Excel.Application
Private Sub xlApp_WorkbookOpen(ByVal Wb As Workbook)
Dim myWindow As Window
On Error Resume Next 'just in case the workbook's windows are protected
For Each myWindow In Wb.Windows
myWindow.WindowState = xlMaximized
Next myWindow
End Sub

Select Insert|class module from the menubar.
it should be called Class1.
Paste this into that code window.

Option Explicit
Public WithEvents xlApp As Excel.Application
Private Sub xlApp_WorkbookOpen(ByVal Wb As Workbook)
Dim myWindow As Window
On Error Resume Next 'just in case the workbook's windows are protected
For Each myWindow In Wb.Windows
myWindow.WindowState = xlMaximized
Next myWindow
End Sub

Save this workbook.
close this workbook

Reopen this workbook and try opening a file that was saved less than maximized.

If it works, close excel and put this workbook in your XLStart folder. Then
when excel starts, this workbook will be opened and you'll be set. (In fact,
I'd save this file as an addin (still in xlstart), so when it opens, it's out of
the way.)

If you want to read more about them, visit Chip Pearson's site:
http://www.cpearson.com/excel/AppEvent.htm

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

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

Top