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

Non-spammers: Thanks for visiting! Please go ahead and leave a comment; I read them all!

Attention SPAMMERS: I review all comments before they get posted, and I REPORT 100% of spam comments to Google as spam! Why not avoid getting your account banned as quickly -- and save us both a little time -- by skipping this comment form and moving on to the next one on your list? Thanks, and I hope you have a great day!