Another missing reference thread (1 Viewer)

systemx

Registered User.
Local time
Tomorrow, 06:38
Joined
Mar 28, 2006
Messages
107
Hi all,

My apologies first for making another thread on this issue. I have tried all solutions I have managed to locate with no success.

I am developing in Access 11. A small percentage of my users are using Access 9. When the Access 9 users attempts to open the database, the 'Outlook' reference is broken.

I am attempting to automate the process of removing the broken reference and adding the correct based on the version number.

I have found three methods -

1. Microsoft method

Code:
Dim loRef As Access.Reference
    Dim intCount As Integer
    Dim intX As Integer
    Dim blnBroke As Boolean
    Dim strPath As String

    On Error Resume Next

    'Count the number of references in the database
    intCount = Access.References.Count
  
    'Loop through each reference in the database
    'and determine if the reference is broken.
    'If it is broken, remove the Reference and add it back.
    For intX = intCount To 1 Step -1
      Set loRef = Access.References(intX)
      With loRef
        blnBroke = .IsBroken
        If blnBroke = True Or Err <> 0 Then
          strPath = .FullPath
             With Access.References
            .Remove loRef
            .AddFromFile strPath
          End With
        End If
       End With
    Next
    
  Set loRef = Nothing
  
  ' Call a hidden SysCmd to automatically compile/save all modules.
  Call SysCmd(504, 16483)

Note: Using this method the broken reference has strPath NULL. Not sure whether this is relevant.

2. Using code found on this forum

Code:
Dim intCount As Integer

For intCount = Access.References.Count To 1 Step -1
    Set ref = Access.References(intCount)
        If ref.IsBroken Then
            Access.References.Remove ref
        End If

Note: This method generates an error message (I cannot replicate right at this moment but it is something like 'Object not found in library'

3. Unload references at close and load at startup

Code:
References.Remove (Outlook)
References.Remove ("C:\Program Files\Microsoft Office\OFFICE11\msoutl.olb")

The remove reference function fails for me - have tried both of the above lines of code.

Can anyone suggest another solution or point out where perhaps I may be going wrong with this?

Thanks,

Rob
 

Bat17

Registered User.
Local time
Today, 23:38
Joined
Sep 24, 2004
Messages
1,687
I have no answer to your problem directly, but it may be worth looking at Late Binding versus Early Binding. With late binding you don't require references so you don't get the version problems.

have a look here or do a google search on late binding outlook
http://www.dicks-clicks.com/excel/olBinding.htm

HTH

Peter
 

MarkK

bit cruncher
Local time
Today, 15:38
Joined
Mar 17, 2004
Messages
8,181
I believe that MS Office references are automatically carried forward if a newer version is detected. You might try to copy your development version to a machine equipped with Office 9, set your references, and then distribute.

I use late binding, as mentioned by Bat17. Simply...
Code:
  Dim olApp as New Outlook.Application
  'becomes...
  Dim olApp as Object
  Set olApp = CreateObject("Outlook.Application")
For enumeration members I've redefined them as constants in a standard module...
Code:
  Public Const olMailItem = ?
 

Bat17

Registered User.
Local time
Today, 23:38
Joined
Sep 24, 2004
Messages
1,687
I believe that MS Office references are automatically carried forward if a newer version is detected.
Yep, but they are not carried back again, so it can update itself to the new version and ppl with the older version get the error :-(

Peter
 

KeithG

AWF VIP
Local time
Today, 15:38
Joined
Mar 23, 2006
Messages
2,592
I agree with Bat17 try using late binding instead of early binding. You won't be able to use the intellesense feature in VBA with you Outlook object though
 

RuralGuy

AWF VIP
Local time
Today, 16:38
Joined
Jul 2, 2005
Messages
13,826
You can use the conditional compile #If #Else #End If with a #Const so the intellisense works during development.
 

bluegno

Registered User.
Local time
Today, 15:38
Joined
Nov 30, 2005
Messages
27
systemx, did you come up with (or choose) a solution?

I have the same issue, and am seeking a programmatic fix.

(Note: Late binding seem like a last resort solution; I support tens of thousands of lines of VBA, and can't imagine that conversion to late binding would be simple....)
 

Users who are viewing this thread

Top Bottom