×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Automatic Load Solver.xla

Automatic Load Solver.xla

Automatic Load Solver.xla

(OP)
Dear All,

I realised that not all Excel comes with Solver.xla "checked" as default (in Visual Basic Module). As a result, some of the macro I wrote which uses solver will not work in those computers unless the user manually select the solver check box.

Hence, I am wondering if anyone could teach me how to write a script which load Solver.xla automatically as part of a macro.

Many thanks!

EK

RE: Automatic Load Solver.xla

You should be able to load it through:

AddIns("Solver Add-In").Installed = True

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.

RE: Automatic Load Solver.xla

(OP)
Dear Dsi,

I tried your method by uncheck the solver and run the line which you recommended but it does not work. Do I need to specify the path to the library etc?

Thanks again.

EK

RE: Automatic Load Solver.xla

It seems to work OK, both  in the explicit and implicit versions:

    AddIns("solver add-in").Installed = True
or
    AddIns.Add("solver.xla").Installed = True

Note that the spelling and punctuation must be exact.  The explicit version does require you to know the actual file name, which, for Solver, is not too hard to figure out.  

TTFN

RE: Automatic Load Solver.xla

(OP)
Dear TTFN,

I tried the following code without checking the SOLVER.xla box manually and it won't work. Could you see anything wrong in the code?

The error message is:

"Compiled Error"
"Sub or Function Not Defined"

If I checked the solver.xla manually, it works fine.

Thanks again.

_____________________________

Sub Solver300()

' Solver used to solve stud with 300 spacing
'

AddIns("solver add-in").Installed = True

SolverReset
SolverOptions Iterations:=10000, Precision:=0.01
SolverOk SetCell:="$G$16", MaxMinVal:=3, ValueOf:="0", ByChange:= _
"$B$15,$B$17,$B$18,$B$19,$B$20,$B$21,$B$22,$B$23"

SolverAdd CellRef:="$G$17", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$G$18", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$G$19", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$G$20", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$G$21", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$G$22", Relation:=2, FormulaText:="0"
SolverAdd CellRef:="$G$23", Relation:=2, FormulaText:="0"
      
    SolverSolve UserFinish = False

End Sub

___________________

RE: Automatic Load Solver.xla

sorry, I can't get the code to run either way, so there's something missing, like some sort of register command that registers the subcalls in the library?

TTFN

RE: Automatic Load Solver.xla

Sorry, you must be talking about the References Solver box.  That has to be checked, since that's the only way the VBA knows what the subcalls are.  I don't think there's any way around that.

TTFN

RE: Automatic Load Solver.xla

Another way is to check SOLVER library in Tools-preferences in VBA project. When it's checked the solver add-in will be activated automatically every time you open spreadsheet. (Assuming it's been installed during MS Office installation).

RE: Automatic Load Solver.xla

(OP)
Thanks IRstuff and yakpol. I have tried yakpol's method and it works.... but only with office installed in the same directory and drive. I guess that is good enough considering most people install their office in "c:\program files" except those with dual boot.

Anyway, thanks for all your help and time.

EK

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources