Invalid use of New keyword

The New keyword can only be applied to a creatable object (an instance of a class or Automation object). This error has the following causes and solutions:

  • You tried to instantiate something that can have only one instance. For example, you tried to create a new instance of a module by specifying Module1 in a statement like the following:

      Dim MyMod As New Module1 
    

    You can't create the new instance, since a module can have only one instance.

  • You tried to instantiate an Automation object, but it was not a creatable object. For example, you tried to create a new instance of a list box by specifying ListBox in a statement like the following:

        ' Valid syntax to create the variable. 
      Dim MyListBox As ListBox     
      Dim MyFormInst As Form 
      ' Invalid syntax to instantiate the object. 
      Set MyFormInst = New Form 
      Set MyListBox = New ListBox 
    

ListBox and Form are class names, not specific object names. Use them to specify that a variable will be a reference to a certain object type, as with the valid Dim statements above. But you can't use them to instantiate the objects themselves in a Set statement. You must specify a specific object, rather than the generic class name, in the Set statement:

    ' Valid syntax to create new instance of a form or list box. 
  Set MyFormInst = New Form1 
  Set MyListBox = New List1 

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.