Solver VBA control

  • Thread starter Thread starter ChrisK
  • Start date Start date
C

ChrisK

Hi,

I'm controlling Solver via VBA. But to do this you must add in SOLVE
via the Tools References within VBA. If you don't do this first th
macro crashes. However, as I'm going to give this worksheet to othe
people is there a way to either automatically add SOLVER in within VB
or to check it it's loaded?

Any help would be appreciated.

Thanks

Chri
 
if you want to set the reference with code, here is some code posted by Dana
DeLouise

http://groups.google.com/groups?threadm=#[email protected]

Sub SolverInstall()
'// Dana DeLouis
Dim wb As Workbook

On Error Resume Next
' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

With AddIns("Solver Add-In")
.Installed = False
.Installed = True
wb.VBProject.References.AddFromFile .FullName
End With
End Sub


This line adds the reference:
wb.VBProject.References.AddFromFile .FullName

The other parts make sure it is loaded as an addin.
-----------------------------------------------------


----------------- an article you might find useful:



http://support.microsoft.com/support/excel/content/solver/solver.asp
Creating Visual Basic Macros that Use Microsoft Excel Solver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top