Losing Module Level ENums in Excel 2003

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



This is driving me crazy!

I have a bunch of constants and Private Enums declared at the top of my
regular module.

e.g.
(I've paired this down for brevity.)

Private Const mcstrDataWorksheetName As String = "DataSheet"
Private mstrArray() as String
Private Enum eStageName
LBoundIndex = 1&
Text = 1&
DatabaseName = 2&
DisplayName = 3&
UBoundIndex = 3&
End Enum

Private Enum ePropertyIndex
LBoundIndex = 1&
Text = 1&
DisplayName = 2&
DefaultValue = 3&
Unit = 4&
UBoundIndex = 4&
End Enum

I use them like

Dim mstrArray(ePropertyIndex.LBoundIndex To ePropertyIndex.UBoundIndex)

Everything have been working fine for several weeks ... except
Every now and then, the Enums stop working! It's always after some
debugging, trying things, making some mistakes, and then, making some change
in a section of code that is seemingly unrelated to Enums, the next time I
try and run the program I get the following:

Microsoft Visual Basic
Compile Error:
Constant expression required.

And it goes to the first spot in my LoadObjects routine that uses an Enum,
with the member highlighted. (the Dot and DisplayName are highlighted)

ePropertyIndex.DisplayName

NOTE: Commenting out the line simply moves the error to the next Enum. If I
comment out every enum used in the Sub, it will recognize other module level
variables and constants. But will give me the same compile error whenever it
runs across the next Enum. I comment out everything I was just changing and
it won't run.

Sometimes, restarting Excel "fixes" the problem, sometimes rebooting the box
"fixes" the problem, other times, it just refuses to work and at what seems
like an arbitrary time in the future, it works again.

Anybody got any ideas?

TIA, Bob
.



Relevant Pages

  • Re: How to provide a list of value when passing a paramater...
    ... Private Enum RegisterHotKeyModifiers ...
    (microsoft.public.vb.general.discussion)
  • RE: Losing Module Level ENums in Excel 2003
    ... Compile under the Debug Menu, ... DisplayName = 3& ... Private Enum ePropertyIndex ...
    (microsoft.public.excel.programming)
  • Re: return a private enum
    ... I may need a set/get but I don't know how to do that on an enum. ... public class SomeClass ... private enum Status; ... return NOK; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: nested enum
    ... For example, private enum inside0 ... public enum inside0 implements outside ...
    (comp.lang.java.help)
  • Re: Whats this service?
    ... the path field is blank. ... registry and this is what I found there: ... Value= DisplayName Data=Senarpnkdpns ... Closest thing to a path is in Enum: ...
    (microsoft.public.security)