Reference Link MISSING when opened from an older version

jeffmoseler

Well-known Member
Joined
Jul 16, 2004
Messages
539
I have the following code in a Function in Excel:

Code:
thisVINCharacter = Mid(workingvinnumber, x, 1)

Everytime someone opens it in Excel 2013 it updates the References from "Microsoft Outlook 14.0 Object Library" to "Microsoft Outlook 15.0 Object Library" . Then when I open it in Excel 2010 it errors out on the line above, highlighting the "Mid" function.

Is there a way to get the code to run regardless of the Object Library version?
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

DocAElstein

Banned user
Joined
May 24, 2014
Messages
1,336
I have the following code in a Function in Excel:

Code:
thisVINCharacter = Mid(workingvinnumber, x, 1)
....... . Then when I open it in Excel 2010 it errors out on the line above, highlighting the "Mid" function.......

. Hi Jeff,
. Not sure if this may Help…..
. I sometimes have similar problems with the VBA Left, Right and Mid Functions. Sometimes when I open up a file in XL 2007 which was saved in XL 2010 the VBA Left, Right and Mid Functions suddenly do not work giving a compiling error I guess similar to which you are experiencing.
. It appears to be related to the different Libraries, but as a Beginner I am not too sure of exactly where the problem lies.
. However the following has up until now always solved the problem for me:- Replace all these functions with the following
Left replace with VBA.Left
Right replace with VBA.Right
Mid replace with VBA.Mid
. The code then always works for me regardless of the XL version
. You may get some more insight into the problem from Zack Barresse here
http://www.mrexcel.com/forum/excel-...ions-functions-such-date-time-left-etc-2.html


Alan Elston.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,770
Office Version
  1. 2010
Platform
  1. Windows
I don't know how you're using Outlook objects in your code, but if you switch from early to late binding, you can remove the reference to Outlook.

E.g., change from

Code:
  Dim oOL As Outlook.Application
  
  Set oOL = New Outlook.Application

to

Code:
  Dim oOL As Object
  
  Set oOL = CreateObject("Outlook.Application")

... and remove the reference. The code will load the latest libabry when it runs.

The downside is that you lose Intellisense for the Outlook objects, but that can be circumvented using conditional compilation, which allows you to develop early-bound and deploy late-bound.
 

DocAElstein

Banned user
Joined
May 24, 2014
Messages
1,336
.. Just a quick last note from me… I was playing around again just now with my solution and that from shg. Both seem always eventually to work. But there is a small catch to be aware of. Changing / removing references or attempting my VBA. Solution sometimes was not allowed or gave a strange “ddl” error.
. Up until now restarting excel has usually done away with those issues.…and so finally both solutions always then seemed to work.
Alan.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,020
Messages
5,545,535
Members
410,690
Latest member
navneetr
Top