Tuesday, October 13, 2015

Resolving or fixings compiler error in VBA

Hello Friends,
Most of the times we face compiler error even we have written all the code correctly.

Cause:

When we get "Compiler Error in hidden module" error that means Your excel project is missing one or more reference libraries or its not properly registered. 

Identify:
When you get such error goto VBA Editor window and check all libraries under Tool->Library and you wil find word missing before library name which is causing an error.

Fix:

If library is missing:

For temporary fix you can select lower version of library.

 For example if your project is showing Microsoft Active Data Object 6.1 library as missing then you can select Microsoft Active Data Object 2.0 which is a lower version. 

Or you can try permanent solution: Download that library and store on users machine and register it using below command

Open command prompt and type

Regsv32 "complete path of library"

If library is available on user machine and still showing as missing:

Then first unload library using below command and then register it.

Regsv32 /u "complete path of library"

How to avoid this error:

Write your library dependant object code in late binding form

Learn excel VBA online from an industry experience developer to strengthen your knowledge go for a structured VBA course. 

How to fix automation error in VBA-Marco

If you are getting automation error in your VBA protect. Then below steps possibly fix your problem:
Cause:
Such issue can arise due to mscomctl.ocx file which is an common control library
Fix:
If your project is throwing an error on specific machine then it can be a version issue of common control library. In such situations cross check version of culprit library with one on working machine. if any discrepancy found then take library from working machine and replace with culprit machine.
Mostly you will find such library in system32 folder or you can search them in file system or you can also see location in Tools->Library menu in VBA editor window of VBA by selecting respective library as shown below:

Once you replace library then register library with below command in command prompt or Run window:

Regsv32 /u "complete path of library"

to unload file then 

Regsv32 "complete path of library"

to register file. if you get any error then try with admin access.

Thursday, April 9, 2015

Questions

You can post your questions in comments section of this post and I will revert you back.

Thank you