我有两个Excel文件(一个是xlam,另一个是xlsm)。 xlsm引用了xlam。
如果我在打开xlam之前打开xlsm,Excel会崩溃。
从使用xslm(使用任何编程方法)有一种方法我可以检查xlam是否打开,如果没有,要么动态加载它,要么在退出之前显示需要先打开xlam的警告。
我制作了一些从xlsm
中的Workbook_Open子调用的代码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
不幸的是Excel在达到Workbook_Open之前崩溃了
答案 0 :(得分:1)
这样的东西?
'/**
'
' VBA Function to check whether required addin is installed...
' @version 1.0
' @author Ilyas Kazi http://ilyaskazi.com
'
' @param string str_filename (to parse file name to lookup for the addin)
'
' @return boolean (true/false)
'
'**/
Function IsAddin_Installed(str_filename As String) As Boolean
Dim aiwb As AddIn 'addin workbook
For Each aiwb In Application.AddIns 'Loop through each addin workbook
If UCase(aiwb.Name) = UCase(str_filename) Then
IsAddin_Installed = True 'found
Exit Function
Else
IsAddin_Installed = False
End If
Next
End Function
答案 1 :(得分:0)
如何将XLAM添加为VBA参考?有没有办法让XLAM保持在集中位置?