Every VBA project requires references to external libraries. At a
minimum, you need references to VBA, OLE, Office, and Excel. You can
safely assume these will be in place on any machine running a
compatible version of Excel. However, if your project requires other
libraries, it is not safe to assume that these will exist on another
machine. If a required library cannot be found on the machine on which
the code is to be run, you can get odd errors, such as the compiler
complaining that some fundamental VBA function (e.g. Left) cannot be
found. This can be confusing because the library that contains the
bitched at command (eg., Left, defined in the VBA typelib) is clearly
in place. The absence of one library can cause the compiler to
complain about functions defined in other libraries.
On the machine that is exhibiting the problems, open the workbook and
then open the VBA editor. There, go to the Tools menu, choose
References, and look for any reference(s) marked as "MISSING". If a
library is missing, you can do one of two things. If you don't really
need the library, you can uncheck it and forget about it. If you do in
fact need the library, you'll need to copy the library file from a
well working machine (assuming you have the legal right to copy and
distribute the file) to the machine that has the problems. Once
copied, you'll likely need to register the library with Windows. Close
out Excel, go to the Windows Start menu, choose Run, and enter the
following, including the quotes as shown. Of course, use the
appropriate file path to the file name.
RegSvr32 "C:\Path\To\File\Filename.dll" /u
Then, do the same thing but without the /u switch:
RegSvr32 "C:\Path\To\File\Filename.dll"
Now, restart Excel and open the workbook.
If you are not able to copy the requisite library to the problematic
machine, then your workbook, as is, cannot be used on that machine.
If you have access to a real installation file builder, such as
InstallShield, Setup Factory, or Advanced Installer, you can create a
setup and deployment project that will automatically copy the required
libraries to the the user's machine and register those libraries with
Windows.
Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]