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

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

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


Compile Error - Invalid outside procedure


Compile Error - Invalid qualifier


Compile Error - Only user defined types defined


Compile Error - Procedure too long



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


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


Cannot run Visual Basic macro because of a syntax error








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