Fix for VBA’s user-defined type not defined error


I used your example code at, which transfers Word form data to an Excel sheet. Unfortunately, the code returns the error: the user-defined type not defined. Can you help? — Cheslei

Cheslei, that error usually means one of two things:

  • You need to reference the library that supports the specified type.
  • There’s a typo in the object variable name.

To add a reference, in the Visual Basic Editor (VBE), do the following:

  1. Choose References from the Tools menu.

  2. In this case, check the Microsoft ActiveX Data Objects 2.x Library (ADO). It isn’t enough to highlight the library item; you must check it.

  3. Click OK to return to the module.

If you tried to copy the code directly from’s web page into a VBA module using a copy/paste operation, the quotation marks will also cause trouble. You can replace them or you can download the demo file.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s