I have two Excel files (one a xlam and the other a xlsm). The xlsm references the xlam.
If I open the xlsm before opening the xlam, Excel crashes.
From with the xslm (using any programmatic method) is there a way I can check to see if the xlam is open and if not, either load it dynamically or show a warning that the xlam needs to be opened first before exiting.
I crafted some code which gets called from the Workbook_Open sub in the xlsm
Public Function checkReferences() As Boolean
On Error Resume Next
Dim retVal As Boolean
retVal = False
Dim i As Integer
For i = 1 To ThisWorkbook.VBProject.References.Count
With ThisWorkbook.VBProject.References(i)
If StrComp(.name, "PreTradeServices") = 0 Then
retVal = True
Exit For
End If
End With
Next i
checkReferences = retVal
End Function
Unfortunately Excel crashes before that Workbook_Open is reached