问题描述:

I'm trying to work with the Solver Add-In in VBA for Excel 2010 and whenever I go to add the reference under Tools->References I get an error about accessing the system registry. I'm not the admin on the computer I'm using, so I can't go playing around with the registry to fix it. I also tried adding it as a reference from a macro (which I added below), but when I run that I get an "Error in loading DLL" error. Is there any way I can get these functions to use in VBA?

Option Explicit

Private Sub Workbook_Open()

Call JR_LoadSloverReference

End Sub

Function JR_TestSolverReference() As Boolean

Dim obj

For Each obj In ThisWorkbook.VBProject.References

If UCase(obj.Name) = "SOLVER.XLS" Then

JR_TestSolverReference = True

Else

JR_TestSolverReference = False

Exit For

End If

Next obj

Exit Function

End Function

Sub JR_LoadSloverReference()

If JR_TestSolverReference = False Then _

ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files (x86)\Microsoft Office\Office14\Library\SOLVER\SOLVER.XLA")

Exit Sub

End Sub

相关阅读:
Top