LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Referencing and loading Solver programatically - how?

Hi all
I want to load and reference solver in a spreadsheet if its not already
referenced/opened, but I am having some problems.

Here's my code below. I find that SolverInstall runs ok, but if Solver
is not referenced already from VBA or is MISSING, then SolverAutoOpen
fails with the project not referenced. I have to save the workbook
after running SolverInstall and then close/reopen it for solver to be
referenced properly. I am running the SolveIt macro below from a Vb6
application. Can anyone help with a foolproof way to get Solver always
referenced and loaded first time (from vb6)?

Thanks
Andrew

Dim sh1 as worksheet
Sub SolveIt()
SolverInstall
SolverAutoOpen
sh1.Activate
SolverOk SetCell:="$K$63", MaxMinVal:=2, ValueOf:="0",
ByChange:="$K$54:$K$61"
SolverSolve UserFinish:=True
End Sub
Sub SolverInstall()
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
Sub SolverAutoOpen()
If Not SOLVER.AutoOpened Then
SOLVER.Auto_open
End If
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solver model loading problem marineCORVETTEran Excel Discussion (Misc queries) 0 July 17th 08 11:31 PM
referencing a different tab by referencing a list in the current s Kevin Excel Worksheet Functions 3 July 6th 07 07:57 PM
Interesting Solver problem (Solver encounters an error) MrShorty Excel Discussion (Misc queries) 3 December 22nd 05 10:52 PM
Programatically access Excel's Solver? Kevin R[_2_] Excel Programming 3 February 3rd 05 07:40 PM
Resetting Solver Manually to Fix Solver Bug Stratuser Excel Programming 0 September 13th 04 07:04 PM


All times are GMT +1. The time now is 09:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"