ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2003 won't run simple code that Excel XP and Excel 2000 will run (https://www.excelbanter.com/excel-programming/321724-excel-2003-wont-run-simple-code-excel-xp-excel-2000-will-run.html)

Moses[_2_]

Excel 2003 won't run simple code that Excel XP and Excel 2000 will run
 
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?


Lonnie M.

Excel 2003 won't run simple code that Excel XP and Excel 2000 will run
 
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.


Lonnie M.

Excel 2003 won't run simple code that Excel XP and Excel 2000 will run
 
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.


LaughterAndDeath

Excel 2003 won't run simple code that Excel XP and Excel 2000 will run
 
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?



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Moses[_2_]

Excel 2003 won't run simple code that Excel XP and Excel 2000 will run
 
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?



All times are GMT +1. The time now is 01:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com