我正在尝试检查加载项是否已安装并正在运行。我正在使用这段代码:
On Error Resume Next:
Set SolverNome1 = AddIns("Solver Add-In") 'Solver may have two different names
Set SolverNome2 = AddIns("Solver")
MsgBox IsEmpty(SolverNome1)
MsgBox IsEmpty(SolverNome2)
If IsEmpty(SolverNome1) And IsEmpty(SolverNome2) Then
MsgBox "Install Solver add-in before trying to install this add-in.", vbExclamation
Application.myAddInName.Installed = False 'uninstall my add-in
End If
问题在于,即使使用Solver Uninstalled,我仍然会得到IsEmpty(SolverNome1)= false,因此我的条件子句不能按预期工作。我想在那里我误解了安装与否的概念。我应该用什么代码来检查解算器是否正在运行?
答案 0 :(得分:0)
回答我的问题: 有必要访问.installed属性,如下所示:
myBoolean1 = SolverNome1.Installed'将返回false,因为加载项已设置且未安装 myBoolean2 = SolverNome1.Installed'因为未设置加载项而无法返回