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
- Open Excel workbook and press Alt + F11 to get Visual Basic Editor (VBE)
- Go to the Tools menu and select References from the drop down menu.
- “References– VBAProject” dialog will appear.
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
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
Once you add the FM20.DLL, you can see the Microsoft Forms 2.0 Object Library” is added to the reference list