Removing missing Reference with VBA (1 Viewer)

chacal

Registered User.
Local time
Today, 05:58
Joined
Jun 1, 2005
Messages
40
Hi everyone,

I'm trying to build a module that is verifying the references of my project and adjust them if necessary. It works quite good except when I try to remove the Missing References from the list.
here is the code that I use to remove them:
Code:
          With Access.References
             .Remove Access.References(IntX)
          End With
Where IntX is the index of the missing reference in the reference list.
When I'm executing it, It act like if it is removing it but in fact, it doesn't.

Thanks in advance for your responses.
 

chriswies

Registered User.
Local time
Today, 11:58
Joined
Nov 30, 2005
Messages
16
this should work

references.remove references!REFNAME

for example
references.remove references!Word

Christoph

PS:
It would be fine if you post your code so that others can also learn from what you did!
 

modest

Registered User.
Local time
Today, 05:58
Joined
Jan 4, 2005
Messages
1,220
I've also tried to do the same thing that you're doing. My problem was that I was building a module to check for broken references. If they were broken I wanted to remove them and find the new one (all of this was supposed to be done on load).

It didnt work for every case though. So then I decided that it would be best to remove all the references when the database closed and then add the references as it needed them. This also didn't work because the reference list did not save, even though I tried every attempt to save the database and all the settings when the database closed.

If you find a solution I'd like to see it.

My attempt checked the registry for the user's version of Access, it checked for certain .dll files in the registry, it looked for which version of office they had. And it tried to load the newest of all of them.
 

skea

Registered User.
Local time
Today, 12:58
Joined
Dec 21, 2004
Messages
342
Here is something for a start.Its but not backward compartible so it didnt help me much too.
Code:
Sub FixUpRefs()
    Dim loRef As Reference
    Dim strPath As String
    Dim strMessage As String
      Dim strTitle As String
      Dim bytButtons As Byte
    On Error Resume Next
          For Each loRef In References ''
       If loRef.IsBroken Then
       
           strMessage = loRef.FullPath
           strPath = loRef.FullPath
             References.Remove loRef.Name
             References.AddFromFile loRef.FullPath
          Else
         
            strMessage = loRef.FullPath
        End If
        MsgBox strMessage
       'MsgBox strPath
      Next loRef
  'Set loRef = Nothing
  ''Call a hidden SysCmd to automatically compile/save all modules.
  'Call SysCmd(504, 16483)
End Sub

This will give you the names and paths of the references
Code:
Sub ReferenceInfo()
      Dim strMessage As String
      Dim strTitle As String
      Dim bytButtons As Byte
      Dim refItem As Reference

      On Error Resume Next

      For Each refItem In References
         If refItem.IsBroken Then
            strTitle = "MISSING Reference"
            strMessage = "Missing Reference:" & vbCrLf & refItem.FullPath
            bytButtons = 16 'critical symbol
         Else
            strTitle = "Displaying References and Their Locations"
            strMessage = "Reference: " & refItem.Name & vbCrLf & _
            "Location: " & refItem.FullPath
            bytButtons = 64 'information symbol
        End If

      MsgBox prompt:=strMessage, Title:=strTitle, Buttons:=bytButtons

      Next refItem

    End Sub
 
Last edited:

Users who are viewing this thread

Top Bottom