Excel 2003 won't run simple code that Excel XP and Excel 2000 will run

M

Moses

Hi All,

I was wondering if anyone had come across this problem. I have two
separate applications in which Excel 2003 will not run my code.

On one application, it won't recognize a userform when I am in a sub,
but if I call the userform in the parent sub that calls the problem
sub, it will recognize it. Strange!

In the other one, the code is simple:
thisworkbook.activate
sheets("data entry").activate

It chokes on the 2nd line.

I even tried:
thisworkbook.activate
x = activesheet.name

and it choked on that too.

The error is: Run-time error '32809'
Application-defined or object-defined error.

Any ideas?
 
L

Lonnie M.

Hi Moses, I am taking a bit of a stab in the dark, but I have seen some
similar problems if the windows in taskbar option is not turned off. I
use the following code upon opening a workbook:

If Application.Version >= "11.0" Then
Application.ShowWindowsInTaskbar = False
End If

HTH--Lonnie M.
 
L

Lonnie M.

As for the second issue try something like this:

Dim DataEntry As Worksheet
Set DataEntry = Workbook("workbookNameHere.xls").Worksheet("Data
Entry")
'OR if data entry is active:
'Set DataEntry = ActiveWorkbook.ActiveSheet
DataEntry.Activate

HTH--Lonnie M.
 
L

LaughterAndDeath

I don't get it. (Oh, I am Moses, by the way). As Lonnie suggested, I
added something like

Dim DE as worksheet
set DE = sheets("Data Entry")
DE.activate

and now it works.

So, why did it work before in Excel 2000 and Excel 97 but didn't work in
Excel 2003? Is there something to learn here?
 
M

Moses

I don't get it. Lonnie's solution worked.

Instead of this:

sheets("Data Entry").activate

I used the following code:

dim DE as worksheet
set DE = sheets("Data Entry")
DE.activate

and it worked!

Now why is that? Why did the simpler code work in Excel 97 or Excel
2000 but not in Excel 2003?
Does anyone know? Is there something to learn here?
 

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