Removing a broken reference

C

Chuck

I have a database which will be used by people using Office 2000 or Office
XP. The database requires one of the following libraries depending which
version of Office is used:

Office 2000: Microsoft Word 9.0 Object Library
Office XP: Microsoft Word 10.0 Object Library

Now only one of the above libraries can be referenced at one time so I need
to have code that will add the correct one. This works fine.

I also need to be able to check for broken references and remove them if
required. That is turning out to be a problem.

If the database is referencing the Word 10.0 library but it is being used in
an Office 2000 environment, that libary is broken and I need to remove it.

I am trying this code:

Dim refitem As Reference
For Each refitem In Application.References
If refitem.IsBroken Then Application.References.Remove refitem
Next refitem

In an Office 2000 environment, when it reaches the broken Word 10.0
reference I get this error:

Run-time error '-2147319779 (8002801d)':
Object Library Not Registered

Obviously the broken reference is not removed. Anyone has a solution to
this?

Thanks
 
D

Douglas J. Steele

My suggestion would be to forget about trying to change the reference, and
use Late Binding instead. Tony Toews has some introductory information on it
at http://www.granite.ab.ca/access/latebinding.htm Yes, it may be more
efficient to have the reference, but I've never noticed any significant
performance issues with late binding.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top