So yeah, this answer is a bit late, but just in case someone stumbles across this like I did looking for an answer, I figured out the following bit of code to add an excel reference and it seems to work fine, also in MDE/ACCDE!
If Dir("C:Program Files (x86)Microsoft OfficeOffice12EXCEL.exe") <> "" And Not refExists("excel") Then
Access.References.AddFromFile ("C:Program Files (x86)Microsoft OfficeOffice12EXCEL.exe")
End If
If Dir("C:Program Files (x86)Microsoft OfficeOffice14EXCEL.exe") <> "" And Not refExists("excel") Then
Access.References.AddFromFile ("C:Program Files (x86)Microsoft OfficeOffice14EXCEL.exe")
End If
If Dir("C:Program Files (x86)Microsoft OfficeOffice12EXCEL.exe") = "" And Dir("C:Program Files (x86)Microsoft OfficeOffice14EXCEL.exe") = "" Then
MsgBox ("ERROR: Excel not found")
End If
And the refExists references the following function:
Private Function refExists(naam As String)
Dim ref As Reference
refExists = False
For Each ref In References
If ref.Name = naam Then
refExists = True
End If
Next
End Function
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…