Excel Solver VBA Problem

I have a problem with programming Excel solver using vba. I have the following micro in a workbook named "Book2.xls":

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/8/2005'
SolverOk SetCell:="$H$10", MaxMinVal:=2, ValueOf:="0", ByChange:="$G$10"
SolverAdd CellRef:="$G$10", Relation:=3, FormulaText:="$G$11"
SolverOk SetCell:="$H$10", MaxMinVal:=2, ValueOf:="0", ByChange:="$G$10"
SolverSolve userfinish:=True
End Sub

Macro1 runs fine if I open "Book2.xls" manually and either run it through "Tools\Macro\Macros...\Macro1 -> Run " or run it in the VB editor.

I then created another workbook named "Test.xls" with the following code.

Private Sub Workbook_Open()
Workbooks.Open Filename:="C:\test\Book2.xls"
End Sub

With this code, I can open "Test.xls" manually, which then automatically opens "Book2.xls". But when I try to run Macro2 inside "Book2.xls" (either through "Tools\Macro\Macros...\Macro1 -> Run " or in the VB editor), the Solver gives me an error "Solver: An unexpected internal error occurred, or available memory was exhausted".

Does someone have any idea of how to fix this problem?

My original intent was to launch an Excel Workbook from within Microsoft Access and automatically run the Excel solver with the data exported from Access (since Access does not have the solver feature). I was given the same error by the solver when I tried to do so.

[1480 byte] By [cgufl] at [2007-12-23]
# 1
Hi,

Since the problem is reported by a third-party component: Excel solver, it is out of our support team's boudaries and you would need to contact Excel Solver's support team [http://www.solver.com/suppstdvba.htm] for assistance with this issue.

Perhaps someone else here has run across this issue?

Sorry we can't help out with this one.
-brenda (ISV Buddy Team)

MSISVBuddyTeam at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 2
Hi, not sure if it is too late, but I was having the same problem. I was calling the Solver from LabVIEW, and getting the same error. For my case, if I add the:

Application.Run "Solver.xla!Auto_Open"

on the first line of Macro, then I was able to boot the Solver from other app. Maybe it might work...

tetsu-

tetsu- at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 3

i had the same problem here when calling the solver from excel visual basis editor to optimize a portfolio, but when i applied the Application.Run line in my Sub() it was resolved.

Thanks a million pal we are the best

megatiko at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 4
You guys are awesome. I had the exact same problem. I have a database that will open an excel file with solver and some data from the database. The solver is hooked up to the workbook_open command and would always produce that error. I used the application.run line before the solver sub and it worked perfectly.
kdub98 at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 5
I don't understand how you solve the problem in workbook_open command or Application.Run "Solver.xla!Auto_Open".

When I use Application.Run "Solver.xla!Auto_Open" the excel gives error

What should I do?
Thanks

NimaAmin at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 6

Fantastic.. A thousand thanks - I thought I was going mad!

hampk at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 7
Have you added the solver.xla to your addins? If not you can code it to add the solver.xla or you can manually add it to the workbook then save the workbook.
BrandonH.Campbell at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...