Hello MSINL,
Firstly, have you registered your DLL? It is possible Excel requires this DLL to be on the search path. In this case you could move it to \Windows\System32 or it may need to be in the application directory.
To register it, you need to move to the directory where the DLL is located and use the commandline tool RegSvr32. This tool should be on your search path in \Windows\System32.
To Register the DLL
1. Click Start > Run...
2. Type in the Regsvr32.exe MyLibrary.dll Change MyLibrary.dll to the name of your dll.
Add a Project Reference to the VBE- Open your workbook and then press ALT+F11 to open the VBE.
- Press ALT+T followed by the Enter key.
- Scroll down the list until you find Microsoft Visual Basic for Applications Extensibility x.x Object Library.
- Press the Space bar to select it, and press Enter
- Press CTRL+S to save the reference in the project
Once the DLL has been registered, a reference to it can be made at runtime by using the Global Universial Identifier or GUID for short. This is also referred to as a Class ID or CLSID. If you don't know the GUID for your dll then you have to use Find in the Registry.
Finding and Copying the GUID for your DLL
1. Click Start > Run...
2. Type in regedit.exe and press Enter
3. Once the Registry Editor opens, press CTRL+F
4. Type in the name of your DLL
5. Make sure the check box at the bottom labeled Match only string only is not checked.
6. The Search the results for TypeLib keys.
7.Click the key to open it.
8. On the right, you will se a window that lists the Name, Type and Data.
9. Click Name
10. To Copy the GUID, press ALT+E, press M, press CTRL+C
11. To close the Registry Editor, press ALT+F4
Macro to Create Runtime Reference to the DLL
Sincerely,
Leith Ross
Bookmarks