0
votes

I am trying to import data into access 2007 from a MS Word form field.
I have followed the tutorial here: http://msdn.microsoft.com/en-us/library/aa155434(v=office.10).aspx

When I run the VBA code I get a compile error that says "User-defined type not defined". After doing some research I've found that it is likely because I am missing a reference to an object in an object library.
I have the following object libraries referenced:

  1. Visual Basic For Applications
  2. Microsoft Access 12.0 Object Library
  3. Ole Automation
  4. Microsoft Office 12.0 database engine Object library
  5. Microsoft Word 12.0 Object library

The error is thrown when the sub is called here:

Sub GetWordData()

Am I missing a reference, or do I have another problem?

Thanks in advance

1

1 Answers

1
votes

Ensure that you have set a reference to the Microsoft ActiveX Data Objects x.x Library.

In the code window, choose Tools->References, scroll to the library and tick it.

Note that using library references, rather than late binding (Create.Object("Word.Application")), makes it easier to access properties and methods but can mean that your code will not run in other environments.