Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Reference Libraries in Excel WorkBook.

There are set of built in libraries avail­able in excel, few of them are default to your code and rest are optional to be added. These libraries con­tain var­i­ous built in meth­ods, objects and prop­er­ties for these meth­ods and objects. These libraries act same as name­spaces in .Net, pack­ages in Java

Below are the steps for adding ref­er­ence libraries to y

our Excel workbook

  1. Open Excel work­book and press Alt + F11 to get Visual Basic Edi­tor (VBE)
  2. Go to the Tools menu and select Ref­er­ences from the drop down menu.
  3. Ref­er­ences– VBAPro­ject” dia­log will appear.
Reference Libraries

Ref­er­ence Libraries

As you can see the list of avail­able ref­er­ences and check box for each ref­er­ence 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 but­ton from the right and you will be able to use the meth­ods and objects which resides in that library.

If you try to use the object for which the nec­es­sary library is miss­ing then you will end up get­ting error

“Compile error: User-defined type not defined”

Com­pile error: User-defined type not defined”

Exam­ple:

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

Some­times you won’t find the desired ref­er­ences 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 ref­er­ence file — FM.20.DLL

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

Microsoft Forms 2.0 Object library

Microsoft Forms 2.0 Object library

 

You may also like...

2 Responses

  1. Manoj B says:

    Hi Sumit,

    I have gone thro’ most of the chap­ters that u have written.Its superb & very use­full in my cur­rent task ..thanks !

    Cur­rently I am stucked at one point. I want to handle/perform some actions in the Dia­log box. In that dia­log box ther are many objects like list box,text box etc.

    is ther any way to set the val­ues / per­form any actions on these..?

    Thanks..
    Manoj Badgu­jar
    9766256355

  2. michele says:

    Hi, I’ve used this code for many years, but now that I try with excel2010 and windows10, it dont works any­more. I’ve already checked the pres­ence of Microsoft Forms 2.0 Object Library and it’s ok.
    Any sug­gest to find solution?

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: