Application.top=0 fails

G

Guest

The first two lines in sub WorkBook_Open are:
ActiveWindow.WindowState = xlNormal
Application.Top = 0

Most of the time, this works fine. Occasionally the 2nd line fails with:
Run-time error '1004':
Method 'Top' of object' _Application' failed

I am running Excel 2003

What could be causing this and how can I fix it?

MANY thanks for any help.
 
I

isabelle

hi,

With ActiveWindow
.WindowState = xlNormal
.Top = 0
.Left = 0
.Height = Application.UsableHeight
.Width = Application.UsableWidth
End With


--
isabelle



Le 2012-02-15 10:06, (e-mail address removed) a écrit :
 
M

Martin Brown

The first two lines in sub WorkBook_Open are:
ActiveWindow.WindowState = xlNormal
Application.Top = 0

Most of the time, this works fine. Occasionally the 2nd line fails with:
Run-time error '1004':
Method 'Top' of object' _Application' failed

I am running Excel 2003

What could be causing this and how can I fix it?

It sounds suspiciously like a race condition where object _Application
isn't quite ready to have its ".Top" property set if the timing is just
ever so slightly off. Wasting a fraction of a second immediately before
the failing line might be sufficient to cure it.
 

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