F
FatMan
Hello All,
This is my first post here, but I figured I'd give it a shot since I am
really stuck on a problem. Thanks in advance for any help that can be
provided.
The problem has to do with library references. I have a database which
is shared between one Access 2000 user and one Access XP user. Some of
the code in the database requires the Excel Object Model library to be
loaded. This can be easily done using the Tools...References menu in
the VBA editor. So far so good.
However, each time a user opens the database, it tries to load the
library associated with their version of Office. So, for example, if
the database is opened in Access 2000, it looks for the Excel 9.0
Object Model. If the database is opened in Access XP, it looks for the
Excel 10.0 Object Model. This is leading to errors, specifically when
the 2000 user attempts to open the database after the XP user and gets
a missing library error (since they don't have the Excel 10.0 Object
Model library).
I am trying to get around this whole mess by writing some simple code
to search for missing libraries, delete the references, and then
attempt to find the correct Excel library and load it. This code would
be the first thing that would run upon database open.
So far I've been able to loop through all of the references in the
database and check the IsBroken property to tell me what's not working.
I am also able to add a reference using the AddFromGUID method of the
References collection. However, I cannot seem to remove a broken
reference, no matter what I do. Here is a bit of sample code to give an
idea what I'm attempting...
Dim ref As Reference
For Each ref In References
If ref.IsBroken = True Then Application.References.Remove ref
Next
When I attempt to run this in the database containing a missing
reference, I get a "Object Library Not Registered" run-time error. Yet
I have no problem removing the reference manually.
Sorry for the long and rambling email, but I wanted to include as many
details as possible. I feel like I'm one step away from conquering
this whole problem, so if anyone could shed some light on how to
programmatically remove a missing reference, it would be greatly
appreciated.
This is my first post here, but I figured I'd give it a shot since I am
really stuck on a problem. Thanks in advance for any help that can be
provided.
The problem has to do with library references. I have a database which
is shared between one Access 2000 user and one Access XP user. Some of
the code in the database requires the Excel Object Model library to be
loaded. This can be easily done using the Tools...References menu in
the VBA editor. So far so good.
However, each time a user opens the database, it tries to load the
library associated with their version of Office. So, for example, if
the database is opened in Access 2000, it looks for the Excel 9.0
Object Model. If the database is opened in Access XP, it looks for the
Excel 10.0 Object Model. This is leading to errors, specifically when
the 2000 user attempts to open the database after the XP user and gets
a missing library error (since they don't have the Excel 10.0 Object
Model library).
I am trying to get around this whole mess by writing some simple code
to search for missing libraries, delete the references, and then
attempt to find the correct Excel library and load it. This code would
be the first thing that would run upon database open.
So far I've been able to loop through all of the references in the
database and check the IsBroken property to tell me what's not working.
I am also able to add a reference using the AddFromGUID method of the
References collection. However, I cannot seem to remove a broken
reference, no matter what I do. Here is a bit of sample code to give an
idea what I'm attempting...
Dim ref As Reference
For Each ref In References
If ref.IsBroken = True Then Application.References.Remove ref
Next
When I attempt to run this in the database containing a missing
reference, I get a "Object Library Not Registered" run-time error. Yet
I have no problem removing the reference manually.
Sorry for the long and rambling email, but I wanted to include as many
details as possible. I feel like I'm one step away from conquering
this whole problem, so if anyone could shed some light on how to
programmatically remove a missing reference, it would be greatly
appreciated.