Enum VBCompileErrorId
Formally encodes a range of integer values for all VBSyntaxErrorInfo and VBCompileErrorInfo errors.
public enum VBCompileErrorId
Fields
AmbiguousName = 9301An identifier conflicts with another identifier or requires qualification.
learn.microsoft.comArgumentNotOptional = 9339An object stands for the value of its default member where a value is expected - an operand, an argument of a parameter that takes a value, the value of a
Letassignment to a variable of a value type - and its default member takes an argument that nothing gives it: aCollection, whoseItemtakes the key it reads.
MS-VBAL §5.5.1.1 Let-coercion (static semantics), §5.5.1.2.13.👉 The specification asks only for an "accessible default Property Get or function"; MS-VBA also asks that it can be called with no arguments (recorded in Excel), as calling it at run time does (§5.5.1.2.13's "simple data value").
ArgumentRequiredForPropertyLetOrSet = 9321A
Property LetorProperty Setprocedure declares no parameters at all - it has no value parameter to receive the value being assigned.
MS-VBAL §5.3.1.5:property-parameters = "(" [parameter-list ","] value-param ")"-value-paramis never bracketed, so it is always mandatory.ℹ️ Unable to find an official
learn.microsoft.comdocumentation link for this error.ArrayAlreadyDimensioned = 9357A
ReDimstatement re-dimensions an array declared with fixed dimensions.
MS-VBAL §5.4.3.3 ReDim Statement.ArrayArgumentMustBeByRef = 9371An argument of an array parameter of a procedure of the workspace is written
ByVal: an array parameter isByRef, and an array is never passed by value.
MS-VBAL §5.6.13.1 Argument Lists.AssignmentToConstantNotPermitted = 9346The target of an assignment is a constant - one the code declares with
Const, or a member of an enumeration.
MS-VBAL §5.4.3.8 Let Statement.AutomationTypeNotSupported = 9373A name written as a type is a procedural module of a referenced library,
VBA.Strings: a module declares members, and is no type of a value.
MS-VBAL §5.6.16.7 Type Expressions.BlockIfWithoutEndIf = 48A block
Ifhas noEnd Ifstatement before the end of its procedure.
MS-VBAL §5.4.2.8 If Statement.ByRefArgumentTypeMismatch = 9361A variable is passed to a
ByRefparameter declared as another type: the parameter would be a second name for a variable of a type it is not.
MS-VBAL §5.3.1.11 Procedure Invocation Argument Processing.ByValArgumentNotAllowed = 9327An argument is written with the
ByValkeyword in an argument list that is not that of an invocation of an external procedure.
MS-VBAL §5.6.13.1 Argument Lists.CantAssignToArray = 9360An array declared with fixed dimensions is assigned an array.
MS-VBAL §5.4.3.8 Let Statement.CantAssignToReadOnlyProperty = 9341A Let statement assigns a member of an object whose class declares a
Property Getof that name and noProperty Letto assign it with.
MS-VBAL §5.4.3.8 Let Statement.CantChangeDataTypesOfArrayElements = 9369A
ReDimstatement states an element type other than the one the array is declared with.
MS-VBAL §5.4.3.3 ReDim Statement.CaseWithoutSelectCase = 50A
Caseclause belongs to noSelect Casestatement: none is open where it is written.
MS-VBAL §5.4.2.10 Select Case Statement.ConstantExpressionRequired = 9350The value of a constant, or a bound of an array declared with
Dim, is not a constant expression: it reads a variable or calls a function.
MS-VBAL §5.6.16.1 Constant Expressions.DivisionByZero = 9353The value of a constant, evaluated statically, divides by zero.
MS-VBAL §5.6.16.1 Constant Expressions.DoWithoutLoop = 46A
Doloop has noLoopstatement before the end of its procedure.
MS-VBAL §5.4.2.6 Do Statement.DuplicateDeclaration = 9303The specified name is already used at this level of scope.
learn.microsoft.comDuplicateLabelDefinition = 9319A procedure declaration contains more than one statement label definition with the same label value.
MS-VBAL §5.4.1.1 Statement Labels.ℹ️ Unable to find an official
learn.microsoft.comdocumentation link for this error.ElseWithoutIf = 49An
Elsestatement belongs to no blockIf: none is open where it is written.
MS-VBAL §5.4.2.8 If Statement.EndIfWithoutBlockIf = 47An
End Ifstatement ends no blockIf: none is open where it is written.
MS-VBAL §5.4.2.8 If Statement.EndWithWithoutWith = 52An
End Withstatement ends noWithblock: none is open where it is written.
MS-VBAL §5.4.2.21 With Statement.EventArgumentsIncompatible = 9323The arguments of a
RaiseEventstatement are not compatible with the parameter list of the event it raises: there are too many or too few, or one cannot be passed to its parameter.
MS-VBAL §5.4.2.20 RaiseEvent Statement.EventNotDefined = 9322A
RaiseEventstatement names an event that the class module it is written in does not declare, or is not written in a class module at all.
MS-VBAL §5.4.2.20 RaiseEvent Statement.ExitDoNotWithinDoLoop = 9312Exit Dois only valid within aDo...Loopstatement.
learn.microsoft.comExitForNotWithinForNext = 9313Exit Foris only valid with aFor...Nextstatement.
learn.microsoft.comExitFunctionNotAllowedInSubOrProperty = 9314Exitstatement must match the kind of procedure in which it occurs.
learn.microsoft.com👉 Here "Property" must be read as
Property LetorProperty Set, because in MS-VBAExit Functioncan legally exist inside aProperty Getprocedure (VBIDE accepts and corrects it)ExitPropertyNotAllowedInSubOrFunction = 9315Exitstatement must match the kind of procedure in which it occurs.
learn.microsoft.comExitSubNotAllowedInFunctionOrProperty = 9332Exit Subis only valid within aSub: theExitstatement must match the kind of procedure in which it occurs.
learn.microsoft.comExpectedArray = 9307A variable name with a subscript indicates the variale is a VBArrayValue.
learn.microsoft.comExpectedEndWith = 53A
Withblock has noEnd Withstatement before the end of its procedure.
MS-VBAL §5.4.2.21 With Statement.ExpectedFunctionOrVariable = 9340A subroutine is written where a value is expected - an operand, an argument, the value of an assignment - and a subroutine has none: only a value, a variable, a property or a function can be evaluated to a data value.
MS-VBAL §5.6.2.1 Evaluation to a data value.ExpectedIdentifier = 9308Syntax specifies an identifier name in this context, but none was supplied.
ℹ️ Unable to find an official
learn.microsoft.comdocumentation link for this error.ExpectedProcedureNotVariable = 9370A call statement is written on a variable of a module, which is no procedure to call.
MS-VBAL §5.4.2.1 Call Statement.ExpectedSubFunctionOrProperty = 9364A
Callstatement calls something that is not a procedure: a variable, a constant.
MS-VBAL §5.4.2.1 Call Statement.ExpectedUserDefinedTypeNotProject = 9374A name written as a type is a project or a library,
VBA: a project holds modules and types, and is no type of a value.
MS-VBAL §5.6.16.7 Type Expressions.ExpectedVariableOrProcedureNotEnumType = 9377An enumeration,
Color, is written where a value, a variable or a procedure is: its members are values, and it is none.
MS-VBAL §5.6.10 Simple Name Expressions, §5.6.12 Member Access Expressions.ExpectedVariableOrProcedureNotModule = 9363The name of a procedural module is written where a value, a variable or a procedure is expected: a module is none of them, and only qualifies the names of its members.
MS-VBAL §5.6.10 Simple Name Expressions.ExpectedVariableOrProcedureNotProject = 9376A project or a library,
VBA, is written where a value, a variable or a procedure is: a project qualifies the names of what it declares, and is none of them.
MS-VBAL §5.6.10 Simple Name Expressions, §5.6.12 Member Access Expressions.FileAccessNotValidForMode = 9334The
Accessclause of anOpenstatement is not one itsFormode allows:Outputis onlyWrite,InputonlyRead, andAppendisRead WriteorWrite.👉 MS-VBAL §5.4.5.1 states the rule and names no error: the message is the platform's.
ForControlVariableAlreadyInUse = 9358A
Forloop is controlled by the variable of aForloop it is nested in.
MS-VBAL §5.4.2.3 For Statement.ForEachMayOnlyIterateOverACollectionObjectOrAnArray = 9379A
For Eachloop iterates what is no array and no object: it has no elements to iterate.
MS-VBAL §5.4.2.4 For Each Statement.ForWithoutNext = 44A
Forloop has noNextstatement before the end of its procedure.
MS-VBAL §5.4.2.3 For Statement.ForbiddenWithOptionStrict = 8000An
Option Strictdirective or annotation is enforcing stricter semantics that block a number of semantic flags at compile-time:ℹ️ This is a specified error code, not (yet) a language feature.
The VB.NETOption Strictstatement (RD-VBA: "directive") is documented as follows:
🎯 Restricts implicit data type conversions to only widening conversions, disallows late binding, and disallows implicit typing that results in an Object type.
learn.microsoft.comFunctionCallOnLeftHandSideMustReturnVariantOrObject = 9355The target of a Let statement is a call of a function that returns neither a
Variantnor an object, whose default member could be assigned.
MS-VBAL §5.4.3.8 Let Statement.InconsistentPropertyAccessors = 9320A
Property Get,Property Let, andProperty Setsharing a name declare incompatible index-parameter lists, or a property procedure with anOptionalparameter or aParamArrayshares its name with another accessor, or aProperty Set's value parameter is not typedObject,Variant, or a named class.
MS-VBAL §5.3.1.7 Property Declarations.ℹ️ The real VBE bundles all three conditions into one message: "Definitions of property procedures for the same property are inconsistent, or property procedure has an optional parameter, a ParamArray, or an invalid Set final parameter." Only the first (index-parameter equivalence) and third (Set's value type) are literal MS-VBAL static-semantics bullets; the Optional/ParamArray-implies-Get-only consequence is not spelled out verbatim in the spec text, but is confirmed by the real compiler's own error wording.
InterfaceMemberNotImplemented = 9329A class module that implements an interface does not declare the implemented name that corresponds to one of the interface's public variables or methods.
MS-VBAL §5.2.4.2 Implements Directive.InvalidDataTypeForConstant = 9351The value of a constant is of a type no constant can have: an object - the
Nothingliteral.
MS-VBAL §5.2.3.2 Constant Declarations.InvalidEventHandler = 9326A procedure named for a
WithEventsvariable and one of the events of its class is not a valid handler of the event: it is not a subroutine, or its parameter list is not compatible with the event's.
MS-VBAL §5.3.1.8 Event Handler Declarations.InvalidEventName = 9325The name of an
Eventdeclaration contains an underscore, which is what separates the name of aWithEventsvariable from the name of the event in the name of a handler.
MS-VBAL §5.2.4.3 Event Declaration.InvalidImplementedMember = 9330A procedure named for an interface member (
InterfaceName_MemberName) does not correspond to it: it is not the kind of declaration the member needs, or its parameters or its type are not equivalent to the member's.
MS-VBAL §5.3.1.9 Implemented Name Declarations.InvalidImplementsDirective = 9328An
Implementsdirective names a class that cannot be an interface class: the class module itself, a class another directive of the module already names, one whose public members have an underscore in their names, or one whose name collides with another interface's; or two interfaces have names one of which begins with the other followed by an underscore.
MS-VBAL §5.2.4.2 Implements Directive.InvalidLengthForFixedLengthString = 9375A fixed-length
String * nis declared with a length it cannot be: less than 1, or more than 65526 characters.
MS-VBAL §5.2.3.1.4 Variable Type Declarations.InvalidNextControlVariableReference = 9359The variable a
Nextstatement names is not the control variable of theForloop it ends.
MS-VBAL §5.4.2.3 For Statement.InvalidOutsideProcedure = 54A statement that runs is written in the declarations section of a module, outside any procedure.
MS-VBAL §5.1 Module Body Structure.InvalidParamArrayUse = 9305The parameter defined as a
ParamArrayis used incorrectly in the procedure.
learn.microsoft.comInvalidQualifier = 9354A member is accessed on an expression of a type that has no members: a number, a
String, aBooleanor aDate.
MS-VBAL §5.6.12 Member Access Expressions.InvalidReDim = 9306Not every VBArrayValue can be redimensioned.
learn.microsoft.comInvalidUseOfAddressOf = 9367An
AddressOfexpression names a member of a class module, or of an object: only a procedure of a standard module has an address.
MS-VBAL §5.6.16.8 AddressOf Expressions.InvalidUseOfMe = 9317An instance expression (
Me) is invalid outside a class module.
MS-VBAL 5.6.11 Instance Expressions.InvalidUseOfNewKeyword = 9368A variable is declared
As Newof a type that is no class, or of a class it cannot create, or is declaredWithEventsas well.
MS-VBAL §5.2.3.1.4 Variable Type Declarations, §5.2.3.1.2 WithEvents Variable Declarations.InvalidUseOfObject = 9304You tried to use an object in an incorrect way.
learn.microsoft.comInvalidUseOfProperty = 9345A Set statement assigns a member of an object whose class declares a
Property Getof that name and noProperty Setto assign it with.
MS-VBAL §5.4.3.9 Set Statement.InvalidWithEventsType = 9324A
WithEventsvariable is not declared as a specific class that has at least one event, or is declared as the class of the module that contains it.
MS-VBAL §5.2.3.1.2 WithEvents Variable Declarations.LSetAllowedOnlyOnStringsAndUserDefinedTypes = 9343The target of an
LSetstatement is declared as a type other thanString,Variantor a user-defined type.
MS-VBAL §5.4.3.6 LSet Statement.LabelNotDefined = 9309A line label or line number is referred to (for example in a
GoTostatement), but doesn't occur within the scope of the reference.
learn.microsoft.comLoopWithoutDo = 45A
Loopstatement ends noDoloop: none is open where it is written.
MS-VBAL §5.4.2.6 Do Statement.MemberAlreadyExistsInDesigner = 9372A form module's code declares a member with the name of one of the form's controls, which the form's designer already declares a field of the form's class for.
ℹ️ Unable to find an official
learn.microsoft.comdocumentation link for this error. MS-VBA reports it with this message (recorded in Excel).MethodOrDataMemberNotFound = 9316The collection, object, or user-defined type (UDT) doesn't contain the referenced member.
learn.microsoft.comℹ️ The
learn.microsoft.comdocumentation documents this error as both a compile-time and a MethodOrDataMemberNotFound error.
This works only because the documentation includes run-time collection item retrieval - otherwise this error would be purely about a failed member binding.ModuleIsNotAValidType = 9366A declaration names a procedural module as its type: a module declares members, and is no type of a value.
MS-VBAL §5.6.4 Expression Binding Contexts.NamedArgumentAlreadySpecified = 9348A call names the same parameter twice, or names a parameter a positional argument is already given to.
MS-VBAL §5.6.13.1 Argument Lists.NamedArgumentNotFound = 9349A call names a parameter the procedure does not declare.
MS-VBAL §5.6.13.1 Argument Lists.NextWithoutFor = 43A
Nextstatement ends noForloop: none is open where it is written.
MS-VBAL §5.4.2.3 For Statement.NotAllowedAsPublicMemberOfObjectModule = 9337A class module declares a constant, a fixed-length string, an array, a user-defined type or a
Declarestatement as a public member: what an object module exposes is reached through an object, which has no room for them.
MS-VBAL §5.2.3.1 Variable Declarations.NumericLiteralOverflow = 42A numeric literal's value falls outside the range of its type: a decimal literal that overflows its type-declaration suffix (
99999%), an unsuffixed integer or floating-point literal that overflows to infinity, or an unsuffixed&H…/&O…radix literal past 32 bits. See MS-VBAL §3.3.2.ObjectRequired = 9347The target of a Set statement is declared as a type that holds no object.
MS-VBAL §5.4.3.9 Set Statement.OnlyCommentsAfterEndProcedure = 55A statement or a declaration is written after the first procedure of a module, where only procedures and comments may be.
MS-VBAL §5.1 Module Body Structure.Overflow = 9352The value of a constant, evaluated statically, does not fit its declared type.
MS-VBAL §5.6.16.1 Constant Expressions.PrivateTypeInPublicMember = 9336A public member names a private
Enumin its signature - the type of a public variable, of a parameter or the result of a public procedure, of a field of a public user-defined type - or, in a class module, a private user-defined type.
MS-VBAL §5.2.3.1 Variable Declarations, §5.3.1 Procedure Declarations.👉 The message says "user defined types", but MS-VBA accepts a private user-defined type in the public members of a procedural module (recorded in Excel): in a procedural module only a private
Enumis refused.PublicUserDefinedTypeInObjectModule = 9338A class module declares a
Public Type: a user-defined type of an object module is private to it.
MS-VBAL §5.2.3.3 User Defined Type Declarations.RSetAllowedOnlyOnStrings = 9344The target of an
RSetstatement is declared as a type other thanStringorVariant.
MS-VBAL §5.4.3.7 RSet Statement.RangeHasNoValues = 9365A dimension of an array is declared with an upper bound less than its lower bound.
MS-VBAL §5.2.3.1.3 Array Dimensions and Bounds.SelectCaseWithoutEndSelect = 51A
Select Casestatement has noEnd Selectbefore the end of its procedure.
MS-VBAL §5.4.2.10 Select Case Statement.SubOrFunctionNotDefined = 9331The code calls a procedure, or uses a statement, that the language it is written in does not have:
Print "x"in a language where a barePrintis the member of a form there is none of, or a symbol only another language's library declares.
learn.microsoft.comSyntaxError = 1A generic "Syntax error" compile-time error.
learn.microsoft.com👉
RDCore.Parsingshould be giving us much more detailed syntax errors that this.TypeDeclarationCharacterDoesNotMatch = 9335A name is written with a type-declaration character (
%,&,^,!,#,@or$) that is not the type it was declared as:x$ = "a"is fine andx% = 42is not, whenxis aString.
learn.microsoft.comTypeMismatch = 9310The variable or property is of a data type that cannot be let-coerced (implicitly converted) to the specified destination type.
learn.microsoft.comℹ️ The
learn.microsoft.comdocumentation documents this error as both a compile-time and a TypeMismatch error. Since both compile-time and run-time semantics are closely related, this does make sense.TypeMismatchArrayOrUserDefinedTypeExpected = 9362An array is passed to a parameter declared as an array of another type.
MS-VBAL §5.3.1.11 Procedure Invocation Argument Processing.UnspecifiedCompileError = 0A fallback error ID for a compilation error.
⚠️ This value may not reliably be interpreted as a valid compilation error ID.
UserDefinedTypeNotDefined = 9311The data type of a variable or parameter declaration is of an unknown, inaccessible, or otherwise invalid data type.
learn.microsoft.com👉 This error usually has absolutely nothing to do with any user-defined type (UDT) declaration. The term "user-defined" here seems to be rather standing for workspace-defined.
VariableNotDefined = 9302You use the
Option Explicitdirective to protect your modules from having undeclared variables and to eliminate the possibility of inadvertently creating new variables when typographical errors occur.
learn.microsoft.comVariableRequired = 9333An expression that is not a variable is where a variable is required: the target of a
Midstatement, the variable aLine Input #,Input #orGetstatement reads into.
learn.microsoft.comWithExpressionOutsideWithBlock = 9318A with-expression (
.memberor!member) appears where there is no enclosingWithblock to supply its implicit owner.
MS-VBAL §5.6.15 With Expressions.ℹ️ Unable to find an official
learn.microsoft.comdocumentation link for this error.WithObjectMustBeUserDefinedTypeObjectOrVariant = 9378A
Withblock is about a value that is no object, no record and noVariant: it has no members to refer to.
MS-VBAL §5.4.2.21 With Statement.WrongNumberOfArgumentsOrInvalidPropertyAssignment = 9342A procedure is called with more arguments than it declares parameters, or with a named argument when it declares none.
MS-VBAL §5.6.13.1 Argument Lists, §5.3.1.11 Procedure Invocation Argument Processing.WrongNumberOfDimensions = 9356An element of an array declared with fixed dimensions is selected by a number of subscripts that is not its number of dimensions.
MS-VBAL §5.6.13 Index Expressions.
Remarks
👉 The members of this enum are divided into sections.
- 0 to 1: Generic system or fallback defaults.
- 2 to 41: Reserved
- 42 to 999: Reserved for RD-VBA formalized syntax errors (VBSyntaxErrorInfo).
- 1000 to 7999: Reserved
- 8000 to 9299: Reserved for future RD-VBA extensibility.
- 9300+: Formalized MS-VBA compilation errors. This list is currently vastly incomplete.
ℹ️ 93 is for 1993, the year MS-VBA came into existence.