Undefined Variable – Mid, Left, Right not working

Article contributed by Dave Rado

If a user gets this error message and when you go into debug you find that the VB functions Mid, Left and Right aren't being recognised as valid, it almost certainly means that there is a reference to something which is not installed or not registered properly on their machine.  (Well that's better than the following Lotus Notes error message I once got – and I kid you not: *?!*~*)

As a first step, compare the references on their machine with those on yours.  If you see one on theirs which says missing, you're well on the way to fixing the problem (copy the relevant file to their machine and register it).  Or if there is a reference on your machine whuch doesn't appear on theirs, you're equally well on your way to fiixing the problem.

You can also try re-registering :

C:\Program Files\Common Files\Microsoft Shared\VBA\VBA332.DLL

There is an additional gotcha to be aware of, however.  If you create a reference to the Microsoft Calendar 8.0 Object Library using Word  97, and then subsequently save your project in Word 2000, Word gets it's knickers in a twist.  It seems to change the reference on the fly from Calendar 8.0 to Calendar 9.0, and provided the user has Microsoft Calendar installed your code runs okay.

But it does not display the reference to either version of Calendar under Tools + References.   And if Calendar isn't installed, it won't show up as missing.  Which makes troubleshooting difficult, to say the least, especially as you may get the above error message even when running a module which never even calls the userform containing the calendar control.

So if you get the above error message but can't see any missing references in the list, that may mean there is a missing reference to an old version of a DLL or OCX.   In which case you have to go through all your modules, looking for any code that references something which is not ticked in the list of references.  When you find it, you're there.