Excel 2007 SP1 - Faulty 'compile error' message

R

Ron West

When altering XL2007 VBA code in break mode, I often have to declare new
variables (eg with datatypes Boolean and Date) and I frequently get a faulty
'compile error' message saying that there is a "Duplicate Declaration in
Current Scope" when trying to continue.

There is no way out of it except to halt the program and completely restart
it from the beginning.

And, there absolutely definitely isn't a duplicate declaration because I can
compile and run the code with no alterations once I have stopped the code
(and wasted my previous run).
 
S

ShaneDevenshire

Hi,

First - to have to rerun all the step again is tedious so you should insert
a breakpoint at the location where you were force to stop.

Second - if you declare a variable during execution Excel may require you to
restart, regardless of what the message says.

Third - you might be able to reduce the problem by setting Option Explicit
at the top of the module.

There is some info here:

http://support.microsoft.com/kb/212673/en-us
 
R

Ron West

Option Explicit was already declared...

I don't remember having this much trouble with earlier versions of Excel...
 
S

Shane Devenshire

Hi,

There is virtually nothing new in VBA in 2007, so this is pretty much how
things were in previous versions. I haven't actually seen this problem yet
in 2007 so I can't make any comments beyond those I already made.

Cheers,
Shane Devenshire
 

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