WindowState = xlMaximize has opposite effect?!

G

Guest

Hi folks,

In a rather large application written for/in Excel 2000 VBA,
I have the following two statements in the Worksheet_Activate()
sub of one of my worksheets.

ActiveWindow.WindowState = xlMaximized
Application.WindowState = xlMaximized

I'm trying to maximize both the application and the current
workbook window.

Instead of maximizing the window it *minimizes* it as soon as
the Application.WindowState = xlMaximize statement is executed.
Reversing the order had no effect.

I checked the numeric value for xlMaximize, xlNormal, and
xlMinimize via the Intermediate window and I get:

x = xlMinimized (and the others)
?x
-4140 ' maximized
-4137 ' minimized
-4143 ' normal

I tried changing the window state manually and then checking
the WindowState. I get: (the same results)

?Application.WindowState (and the others)
-4137 ' maximized
-4140 ' minimized
-4143 ' normal

Any idea what's going on?

TIA,

David

=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F
David Hansen
 
K

Kalle

Sub WindwosMaximizer()
'Maximize Excel
Application.Parent.WindowState = xlMaximized
'Maximize the rest
ActiveWindow.WindowState = xlMaximized
End Sub
 
T

Tom Ogilvy

Your two lists are the opposite

I get:

? xlMaximized
-4137
? xlMinimized
-4140
? xlNormal
-4143
? application.WindowState ' maximized
-4137
? application.WindowState ' minimized
-4140
? application.WindowState ' normal
-4143

you show maximized and minimized reversed:
x = xlMinimized (and the others)
?x
-4140 ' maximized
-4137 ' minimized
-4143 ' normal

Maybe you have a coding problem.
 
T

Tom Ogilvy

? typename( Application.Parent)
Application

seems redundant.

Application.WindowState = xlMaximized

should work.
 
T

Tom Ogilvy

What is obvious.

Your original code

Sub Tester5()
ActiveWindow.WindowState = xlMaximized
Application.WindowState = xlMaximized
End Sub

works fine??????
 
K

Kalle

It doesn't at least in my enviroment.
Excel 9.0.3821 SR-1
Win2K 5.00.2195 SP4 with all Patches

There must be a flaw somewhere...
Basically I agree with you, but....
wherefrom we want to know what Win and Excel really do.... grins

Tom Ogilvy said:
What is obvious.

Your original code

Sub Tester5()
ActiveWindow.WindowState = xlMaximized
Application.WindowState = xlMaximized
End Sub

works fine??????
 
T

Tom Ogilvy

Excel 9.0.4402 SR-1
Win2K 5.0.2195 SP3 Build 2195

Works like a champ.

--
Regards,
Tom Ogilvy


Kalle said:
It doesn't at least in my enviroment.
Excel 9.0.3821 SR-1
Win2K 5.00.2195 SP4 with all Patches

There must be a flaw somewhere...
Basically I agree with you, but....
wherefrom we want to know what Win and Excel really do.... grins
 
T

Tom Ogilvy

Just to add to the Knowledge, the original code:

Sub AAAMaxWindow()
ActiveWindow.WindowState = xlMaximized
Application.WindowState = xlMaximized

End Sub

worked fine in xl97, SR2, Windows 98 SE.
worked fine in xl95, xl97 SR2, xl2000 (9.9.2027), all under Windows XP
professional
 
K

Kalle

OK. And this is what I exspect as well.
But it doesn't work.
I need to do this strange
app.parent....

Mybe it interfers with some of my other installed programms, what i cant
think of too....

I really got no idea why.
 
D

David Hansen

Tom -
Your two lists are the opposite

That was my fault. I added the -xl... and
screwed it up. It should have been.

?xlMinimized
-4140
?xlMaximized
-4137
?xlNormal
-4143


Obvious, no it really wasn't obvious. I agree
with you that .Parent should not make a difference.
However, when I added .Parent it worked right away
and continues to work. Without .Parent the window
gets minimized.

Putting the code in a code module or behind a
sheet doesn't make any difference either.

Thanks for the help guyz.

David



I get:

? xlMaximized
-4137
? xlMinimized
-4140
? xlNormal
-4143
? application.WindowState ' maximized
-4137
? application.WindowState ' minimized
-4140
? application.WindowState ' normal
-4143

you show maximized and minimized reversed:


Maybe you have a coding problem.
T
 
Top