Can I automate the checking of the "Solver" box in VBA References?

R

robs3131

Hi,

Is there a way to have code check the "Solver" box VBA? FYI - I currently
need to do this manually using the following steps:

- Go to "Tools - Macros - Visual Basic Editor"
- Go to "Tools - References"
- Check the checkbox next to 'Solver' and click 'OK'

Thanks!
 
B

Bill Renaud

If you are writing VBA code to use Solver, simply set a reference to it
once in your project (manually, like you are doing now) and you are done.

If you mean that you need to check to see if Solver is installed on another
user's machine before you attempt to make calls to the Solver routines,
then include this line of code somewhere at the top of your code:

AddIns("Solver Add-in").Installed = True
 
R

robs3131

Thanks Bill. Yeah, I figured out that once you check the box, it remains
checked for that spreadsheet. For some reason I was under the impression
that checking the box was specific to each computer -- similar to installing
Solver on each machine.

Thanks for your feedback.
 
J

Jon Peltier

You may run into problems if the version of Excel, or the Office
installation directory, is different on the computers using the workbook. I
spent weeks trying to get the referencing to work out in this situation,
which was made more difficult by the security of later Office versions.
Finally I resorted to using Application.Run to call Solver, as I describe
here:

http://peltiertech.com/Excel/SolverVBA.html

- Jon
 
B

Bill Renaud

Very interesting! I don't understand how your CheckSolver function gets the
Solver installed correctly the 2nd time after temporarily uninstalling it
(and before running the Auto_open macro). Why wouldn't Solver simply go
back to the same state that it had when you checked
Application.AddIns("Solver Add-In").Installed the 1st time?
 
J

Jon Peltier

Because it doesn't. <g>

It probably seems flip, but this protocol was developed through hours of
frustration.

- Jon
 

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

Top