View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Reference Library Upgrading

As you say, to trap events you need to set a reference to the object
library. Typically such event code would be in an addin that would unlikely
be re-distributed. Providing you as the developer set the reference to the
lowest version of Outlook of any potential user there shouldn't be a
problem.

Developers tend to have multiple versions of Office and will normally have
an appropriate "old" version. However Outlook poses a problem as only be one
version of Outlook can be installed, typically of course that of the newest
version of Office on the system.

Unfortunately it can be difficult if not impossible to programmatically
remove a "too new" reference before replacing with a valid one. One
workaround might be to distribute the addin without the reference. In the
open event check some flag if the reference has been previously added, if
not add the reference and save a flag (hidden cell, registry etc). User must
have "Trust access to VB project allowed".

Regards,
Peter T

"Alan Moseley" wrote in message
...
Your answer is perfectly good, providing that you don't need to hook into
an
Outlook event. I cannot seem to find any sample code which describes how
one
would, for example, act upon an ItemSend event when you have late-bound
your
Outlook Application object.

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Jacob Skaria" wrote:

Instead of referencing; use CreateObject function which creates and
returns
a reference to an Automation object

Dim OutlookApp As Object
Set OutlookApp = CreateObject("Outlook.Application")

http://msdn.microsoft.com/en-us/libr...7z(VS.85).aspx

If this post helps click Yes
---------------
Jacob Skaria


"J Streger" wrote:

Is there any way to stop Excel 2007 from upgrading reference libraries?
I
know probably not but I am getting fed up with the knowledge that I
cannot
utilize the MS Outlook library in any sheets that may be used by both
2003
and 2007 (Currently we have both where I work, which is HIGHLY
annoying).

To explain, if I create a sheet in 2003, I can add MS Outlook Lib 11.0.
If a
2007 person opens it, it permanently upgrades to library to 12.0. Then
if a
2003 opens the sheet, the code fails and the reference needs to be
reset.
This is what I want to stop. It's especially bad with shared sheets as
it
causes a fatal corruption in the file, since the library is still
updated
even if the sheet is shared. VBA gets stripped out in order to recover
it in
2003.

So any solutions out there?

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003