Tools...References shows "MISSING:" in front of 2 references

G

Guest

I have a workbook (wkbk1) that references an xla (wkbk2.xla), both in the
same folder. On my machine it works find, when I upload it to my boss's
machine, the code breaks with "unidentified something or other" referring to
a variable in wkbk2.xla. I then check the references, and wkbk2.xla is
listed, and checked, but the word "MISSING:" is in front of it. I tried
unchecking it and hitting OK, and that removed the reference. But now, if I
go back into "Tools...References..." it won't let me add wkbk2.xla, gives me
the message "Can't add a reference to the specified file". Please help!

Thanks in advance

Mike J
 
P

Peter T

Hi Mike,

I'm not sure why you can't re-set the reference. Does wkbk2.xla have a
unique project-name, if not it should.

Maybe try programmatically removing missing ref's and adding required refs,
eg

Sub RemRefs()
''with ref to Extensibility
'Dim oProj As VBProject
'Dim oRef As Reference

''late binding
Dim oProj As Object
Dim oRef As Object

Set oProj = ThisWorkbook.VBProject
For Each oRef In oProj.References
If oRef.IsBroken Then
Debug.Print oRef.Name
oProj.References.Remove oRef
End If
Next

End Sub

Sub AddRef()
Dim oRef As Object
Dim sFullName As String
Dim sProjName As String

sProjName = "aaTmp"
sFullName = "C:\My Documents\Excel\tmp2b.xls"

On Error Resume Next
With ThisWorkbook.VBProject
Set oRef = .References(sProjName)
If oRef Is Nothing Then
Set oRef = .References.AddFromFile(sFullName)
End If
End With

MsgBox sProjName & vbCr & "Ref is set: " & Not oRef Is Nothing

End Sub

Probably better not to run this in your main addin, so change
ThisWorkbook
to
Dim wb as Workbook
Set wb = Workbooks("myAddinName")

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top