PDA

View Full Version : Is it possible to avoid compile errors programmatically?



Peskarik
09-07-2009, 05:56 AM
Hello, everyone :hi:

The background to my question:

I have created a file that on open automatically takes some values from another file on say drive G, and then some values from Bloomberg (using Data Control library). Unfortunately, I need to run this file on two machines, because Bloomberg machine does not have access to G-drive, and the other machine, which has access to G-drive, does not have Bloomberg on it.

Running the file on Bloomberg machine I can control for missing G-drive with chdir "G:\" function (basically, use an error handler to avoid code that takes current values from G-drive).

Unfortunately, when I open the file on non-Bloomberg machine I immediately get "Compile error: Can't find project or library", because the machine does not have Bloomberg Data Type Library.

I wonder:
is it possible to check programmatically if the requisite Bloomberg library is available, and when it is not available make file NOT run the part of VBA code that depends on the Bloomberg library?


Thank you in advance!

Best,
Sergey

Oorang
09-14-2009, 10:23 AM
The easiest way is to switch to late binding and then put in an error handler for when the object instantiation fails.