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

WordToExcelForm

I used your example code at http://www.techrepublic.com/blog/10things/10-steps-to-transferring-word-form-data-to-an-excel-sheet/3484, 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 TechRepublic.com’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.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s