Error Examples


Compile Error - ByRef argument type mismatch

An argument passed ByRef must have the precise data type.
If the data types are different you will see a "ByRef argument type mismatch" error message.
In this example we are passing an Integer variable when a Long is expected.

Sub CallByRef() 
   Dim number As Integer
   number = 50
   Call MySub(number)
End Sub
Sub MySub(ByRef amount As Long)
End Sub
alt text

Run-Time Error - Invalid procedure

This works for positive values of X but fails for negative values.

Sub NegativeX() 
Dim x As Double
x = -10
If (x < 0) And (VBA.Sqr(x) < 10) Then
'do something
End If
End Sub
alt text

You should use logical assignments as opposed to IF statements will also help performance (ie y = (x = 5)).


Compile Error - Invalid outside procedure

alt text

Compile Error - Invalid qualifier

alt text

Compile Error - Only user defined types defined

alt text

Compile Error - Procedure too long

alt text


Run Time Error - 429 ActiveX component can't create object

If you are running 64-bit Office and there is a reference to a 32-bit dll.


Automation Error - The object invoked has disconnected from its clients

alt text

Automation Error - The callee (server [not server application]) is not available and disappeared; all connections are invalid. The call may have been executed

alt text

Cannot run Visual Basic macro because of a syntax error

alt text

alt text

alt text

alt text

alt text

alt text


© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext