如何在VBA参考中永久打开SOLVER? [英] How to Permanently Turn on SOLVER in VBA Reference?
本文介绍了如何在VBA参考中永久打开SOLVER?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
REFERENCE中的SOLVER必须激活才能在VBA中启用SOLVEROK和SOLVERSOLVE,但每次退出Excel时,VBA始终会自动关闭SOLVER.我该如何强制而不是暂时但不断地激活SOLVER?谢谢.
SOLVER inside REFERENCE must be activated to enable SOLVEROK and SOLVERSOLVE in VBA, but VBA always turns off SOLVER automatically every time I quit Excel. How can I force activate SOLVER not temporarily but constantly? Thanks.
推荐答案
它应该有帮助,但是文件目录取决于您的Office版本(在我的情况下为Office15)
It should help, but the file directory, it depends of your Office version (in my case Office15)
Sub addsolver()
Dim i As Long, x As Long
x = ThisWorkbook.VBProject.References.Count
For i = 1 To x
'Debug.Print ThisWorkbook.VBProject.References(i).Name
'check if Solver reference is already referenced
If LCase(ThisWorkbook.VBProject.References(i).Name) = "solver" Then
MsgBox "Solver is already referenced"
Exit Sub
End If
Next
On Error Resume Next
ThisWorkbook.VBProject.References.AddFromFile "C:\Program Files\Microsoft Office\Office15\Library\SOLVER\SOLVER.XLAM"
On Error GoTo 0
End Sub
这篇关于如何在VBA参考中永久打开SOLVER?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文