Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Referencing two versions Object models

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Referencing two versions Object models

So since I am referencing the ActiveWorkbook throughout the code, would I
reference it through the app object? Or could I create an object to represent
the active workbook.

Additionally, would I need to change the references to other items that are
normally in the Object Library i am trying to reference out? Such as
unqhalified Range objects and what not? VBA assumes that those Range objects
fall under a certain portion of the object model unles you specify otherwise.
So would I have to go through and update those lines with a fully qualified
myObject.Workbooks("Thisworkbook.xls").Sheets(1).R ange("A1:C5") yada yada...

I am just trying to get a handle on how painful this is going to be...

Cory

"Jim Thomlinson" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Referencing two versions Object models

Actually, the BEST way is to do the development in the earlier version of
Excel, to ensure you don't use objects and members added to the newer object
model. As Tim points out, you shouldn't get a warning that the Excel or
Office libraries are missing, it's probably some other library. Also,
sending them the later object library files will probably not work, and will
definitely violate your license and theirs.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Jim Thomlinson" wrote in message
...
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Referencing two versions Object models

they open the file, they are greeted with "Cannot Find Library or some
such
since the VBE is looking for the Office 2003 reference.


How do you arrive at that conclusion? Are you sure it's the Office reference
that's MISSING, and not something else?

Excel should be smart enough to refer to the prior versions (Excel, Office)
when they open it. As a test I tried an XL2003 project out on an
XL2000/Office2000 machine and the references automatically adjusted. I don't
have Office 2003 on that machine.

When you open the 2003 project on the 2002 machine, is the Excel/Office
reference MISSING?


--
Tim Zych
SF, CA

"Cory" wrote in message
...
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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object LIbrary Versions 11.0 - 10.0 [email protected] Excel Programming 6 October 31st 07 03:08 PM
Modelling Object Models John[_88_] Excel Programming 4 October 6th 06 08:24 AM
Object vs Picture Handling in Different Versions of Excel Rif Excel Discussion (Misc queries) 0 October 9th 05 08:43 AM
Code to different object models Wboson Excel Programming 5 September 12th 05 11:25 AM
Object libraries and different ones with different versions HeatherO Excel Programming 0 March 14th 05 06:37 PM


All times are GMT +1. The time now is 01:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"