Thursday, December 17, 2009

Fix: Excel VBA “User-defined type not defined”: DataObject

Problem

An Excel VBA subroutine that involves interaction with the Windows Clipboard fails to run with the error: “Compile error: User-defined type not defined.”  The line of code highlighted by Excel as being the cause of the error includes a reference to the “DataObject” object type.

Solution

(Tested on my machine with Excel 2003 SP3)

In the Microsoft Visual Basic editor:

  • Stop debugging by clicking the “Stop” button on the toolbar (if debugging isn’t already stopped).
  • Tools menu | References
  • In the list of available references, find “Microsoft Forms 2.0 Object Library”, check it, and click OK.  (For me, this was the 2nd unchecked item from the top of the list; it wasn’t sorted alphabetically in the list like most of the rest of the listed items.)
  • Run the macro again.

That’s it!  Hope this helps!

1 comment:

  1. Today I heard about a good software-Excel file fix.I found this tool accidentally and to my surprise utility recovered some of my excel files.Moreover program helped me in seconds and free of cost.

    ReplyDelete

Hi spammers! No need to waste your time here; comments are heavily moderated, so if you like, you can save us both a little time and just move on to the next site. :-)

For everyone else: Thanks for visiting! Your comments are more than welcome!