+ Reply to Thread
Results 1 to 2 of 2

Bug in Excel VBA compiler?

  1. #1
    Matt Werner
    Guest

    Bug in Excel VBA compiler?

    Today a mysterious problem arose after making some edits to a VBA project.
    After adding a few new lines of code, the compiler will no longer compile
    (and run) my subroutine. The compiler reports "Compile error: Constant
    expression required" on a line where I reference a Public Enum.

    The enumeration is properly declared in the (General) (Declarations) section
    of the same module. When editing on the same line of the error, the
    enumeration is recognized by the editor as an option when typing.

    The updates to the new code today have nothing to do with the enumeration or
    the line in which the error is occurring. After REMing out all new code
    from today, the error still persists even though it all worked fine
    yesterday. If I REM out the line with the error, the compiler stops on the
    next line with a reference to a public enumeration.

    I experienced this same problem (with a different project) about a month
    ago. After searching the KB and the Internet to no avail, the problem
    mysteriously went away. Of course, I wasted half a day trying to figure it
    out.

    Then I remembered that the last time I copied all my code from the problem
    subroutine into a new subroutine. I then renamed both subroutines so the
    new one is named with the original name. I performed this same procedure
    today, and poof! - the problem is gone.

    I'm curious if anyone else has encountered this problem and if there is a
    reason why it occurs. I have never been able to locate any KB article on
    this. Obviously, this sort of problem is very frustrating because the code
    is correct.

    Any insight will be greatly appreciated.




  2. #2
    Peter Huang [MSFT]
    Guest

    RE: Bug in Excel VBA compiler?

    Hi

    Thanks for your experience sharing.
    Commonly it is hard to say what is going on without a reproduce scenario.
    But I think you would try to create a new Excel and copy/paste all the code
    to see if that works for you if you have the problem again

    Best regards,

    Peter Huang
    Microsoft Online Partner Support

    Get Secure! - www.microsoft.com/security
    This posting is provided "AS IS" with no warranties, and confers no rights.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1