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:
Choose References from the Tools menu.
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.
- 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.