Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Reference Libraries in Excel WorkBook.

There are set of built in libraries available in excel, few of them are default to your code and rest are optional to be added. These libraries contain various built in methods, objects and properties for these methods and objects. These libraries act same as namespaces in .Net, packages in Java

Below are the steps for adding reference libraries to y

our Excel workbook

  1. Open Excel workbook and press Alt + F11 to get Visual Basic Editor (VBE)
  2. Go to the Tools menu and select References from the drop down menu.
  3. References- VBAProject” dialog will appear.
Reference Libraries
Reference Libraries

As you can see the list of available references and check box for each reference and you will notice that few check boxes are already checked so these are the default libraries which are already added to you excel.

You can select the check box for any of the library you want to add in your excel and click OK button from the right and you will be able to use the methods and objects which resides in that library.

If you try to use the object for which the necessary library is missing then you will end up getting error

“Compile error: User-defined type not defined”
“Compile error: User-defined type not defined”


For using MSForms.DataObject in your code you need library “Microsoft Forms 2.0 Object Library

Sometimes you won’t find the desired references in the list, say you won’t find “Microsoft Forms 2.0 Object Library” in the tool/reference list in that case you need to browse the FM20.DLL file from the system32

Browse reference file -  FM.20.DLL
Browse reference file - FM.20.DLL

Once you add the FM20.DLL, you can see the Microsoft Forms 2.0 Object Library” is added to the reference list

Microsoft Forms 2.0 Object library
Microsoft Forms 2.0 Object library