Referencing two versions Object models
The best way around this is to use late binding. Right now you are using
early binding which meand that in the VBE you have Tools - References -
Microsoft Word 11.0 (or something similar). Using late binding you remove
that reference and use code similar to this...
dim appWord as object
set appword = createobject("word.application")
This creates an instance of Word in whatever version they have. Thus no
problem with references.
The down sides are that the code will be marginally slower (normally not an
issue as the difference is very small). Coding will not have intellisense to
help you (I tend to add the reference for developement purposes and then
change my declarations and remove the references at the end). Finally you
will not be able to use any of the built in constants. You will either have
to use the actual value associated with the constants or create constants of
your own to reference (that is what I do as i have some code to create all of
the constants).
--
HTH...
Jim Thomlinson
"Cory" wrote:
Good afternoon,
I have developed a rather lengthy project in Excel 2003 that I would like to
allow my coworkers to use. Unfortunately they have Office XP/2002, and when
they open the file, they are greeted with "Cannot Find Library or some such
since the VBE is looking for the Office 2003 reference. Now I could just
have them copy the office 2003 .tlb file to the appropriate directory on
their systems, but that portion of the file structure has permissions in
place that keep lowly users such as us from modyfying it and would require an
admin to copy each one by had.
Is it possible to have the code selectively reference different object
libraries based on the version of the Office program running? And if I have
already specified Office11 (Office 2003) libraries will this keep the "Can't
remove control or Reference; in use" message from stopping the show? Thank
you in advance for any hyelp that you might give me on this vexxing matter.
Cory
|