Object variable or With block variable not set

An invalid variable is being referenced. To create an object variable, declare the object variable and then assign a valid reference to the object variable using the Set statement. Similarly, a With...End With block must be initialized by executing the With statement entry point.

To correct this error

  1. Make sure the object variable references a valid object, and specify or respecify a reference for the object.

  2. Make sure you did not use an object variable set to Nothing.

  3. Make sure the object library in which the object has been described has been selected in the Add References dialog box.

  4. Make sure your With block is initialized by executing the With statement entry point.

See Also

Reference

With...End With Statement (Visual Basic)

Concepts

Object Variable Declaration (Visual Basic)