Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Tools References...

I distributed a macro that uses Solver. I supplied instructions to the users
to make sure the Solver checkbox in Tools References... was checked before
trying the macro.

A significant number of people called saying the macro did not work (meaning
they ignored the instructions).

Is there any way for the macro to switch on the reference itself??
--
Gary''s Student - gsnu2007xx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Tools References...

Hi Gary,

See Dana de Louis's code posted
by Tom Ogilvy:

How to run Solver from Visual Basic?
http://tinyurl.com/6fvkaz



---
Regards.
Norman


"Gary''s Student" wrote in message
...
I distributed a macro that uses Solver. I supplied instructions to the
users
to make sure the Solver checkbox in Tools References... was checked
before
trying the macro.

A significant number of people called saying the macro did not work
(meaning
they ignored the instructions).

Is there any way for the macro to switch on the reference itself??
--
Gary''s Student - gsnu2007xx


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Tools References...

From a Rob Bovey post:

The Application.Run approach is the one I would suggest. It doesn't
require a reference to the Solver add-in, but it does require that the
Solver add-in be open in Excel and that the calls to Solver procedure names
be fully qualified, e.g.:

Application.Run "Solver.xla!SolverSolve", False

Because Solver is a demand-loaded add-in, you have to do something a
little strange to make sure it's actually open in the user's instance of
Excel. Run the following two lines of code prior to calling any Solver
procedures:

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

The reason for this is that if the user already has Solver selected under
Tools/Add-ins when they open Excel, Excel will consider the add-in loaded
even though Solver.xla doesn't actually open until you select its menu.
Explicitly unloading it and then reloading it in VBA forces Solver.xla to
open no matter what the user's initial settings were.



Gary''s Student wrote:

I distributed a macro that uses Solver. I supplied instructions to the users
to make sure the Solver checkbox in Tools References... was checked before
trying the macro.

A significant number of people called saying the macro did not work (meaning
they ignored the instructions).

Is there any way for the macro to switch on the reference itself??
--
Gary''s Student - gsnu2007xx


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Tools References...

Try this one. Note that this doesn't need a reference to the VBE
Extensibility.

Sub SolverInstall()

Dim oWB As Workbook
Dim strSolverPath As String

On Error Resume Next

Set oWB = ActiveWorkbook

strSolverPath = Application.LibraryPath & "\SOLVER\SOLVER.XLA"

'to load the .xla
With AddIns("Solver Add-In")
.Installed = False
.Installed = True
End With

'to set the reference
oWB.VBProject.References.AddFromFile strSolverPath

End Sub


RBS


"Gary''s Student" wrote in message
...
I distributed a macro that uses Solver. I supplied instructions to the
users
to make sure the Solver checkbox in Tools References... was checked
before
trying the macro.

A significant number of people called saying the macro did not work
(meaning
they ignored the instructions).

Is there any way for the macro to switch on the reference itself??
--
Gary''s Student - gsnu2007xx


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Tools References...

Thanks!
--
Gary''s Student - gsnu200789


"RB Smissaert" wrote:

Try this one. Note that this doesn't need a reference to the VBE
Extensibility.

Sub SolverInstall()

Dim oWB As Workbook
Dim strSolverPath As String

On Error Resume Next

Set oWB = ActiveWorkbook

strSolverPath = Application.LibraryPath & "\SOLVER\SOLVER.XLA"

'to load the .xla
With AddIns("Solver Add-In")
.Installed = False
.Installed = True
End With

'to set the reference
oWB.VBProject.References.AddFromFile strSolverPath

End Sub


RBS


"Gary''s Student" wrote in message
...
I distributed a macro that uses Solver. I supplied instructions to the
users
to make sure the Solver checkbox in Tools References... was checked
before
trying the macro.

A significant number of people called saying the macro did not work
(meaning
they ignored the instructions).

Is there any way for the macro to switch on the reference itself??
--
Gary''s Student - gsnu2007xx





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Tools References...

Thank you
--
Gary''s Student - gsnu200789


"Norman Jones" wrote:

Hi Gary,

See Dana de Louis's code posted
by Tom Ogilvy:

How to run Solver from Visual Basic?
http://tinyurl.com/6fvkaz



---
Regards.
Norman


"Gary''s Student" wrote in message
...
I distributed a macro that uses Solver. I supplied instructions to the
users
to make sure the Solver checkbox in Tools References... was checked
before
trying the macro.

A significant number of people called saying the macro did not work
(meaning
they ignored the instructions).

Is there any way for the macro to switch on the reference itself??
--
Gary''s Student - gsnu2007xx


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Tools References...

Thanks
--
Gary''s Student - gsnu200789


"Dave Peterson" wrote:

From a Rob Bovey post:

The Application.Run approach is the one I would suggest. It doesn't
require a reference to the Solver add-in, but it does require that the
Solver add-in be open in Excel and that the calls to Solver procedure names
be fully qualified, e.g.:

Application.Run "Solver.xla!SolverSolve", False

Because Solver is a demand-loaded add-in, you have to do something a
little strange to make sure it's actually open in the user's instance of
Excel. Run the following two lines of code prior to calling any Solver
procedures:

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

The reason for this is that if the user already has Solver selected under
Tools/Add-ins when they open Excel, Excel will consider the add-in loaded
even though Solver.xla doesn't actually open until you select its menu.
Explicitly unloading it and then reloading it in VBA forces Solver.xla to
open no matter what the user's initial settings were.



Gary''s Student wrote:

I distributed a macro that uses Solver. I supplied instructions to the users
to make sure the Solver checkbox in Tools References... was checked before
trying the macro.

A significant number of people called saying the macro did not work (meaning
they ignored the instructions).

Is there any way for the macro to switch on the reference itself??
--
Gary''s Student - gsnu2007xx


--

Dave Peterson

Reply
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
VBA---Tools--References automatic Denys[_3_] Excel Programming 4 October 3rd 07 06:40 PM
Tools | References AA2e72E Excel Programming 2 May 18th 06 10:28 AM
VBE ToolsReferences Bill Martin[_2_] Excel Programming 2 February 24th 06 01:17 AM
Tools...References shows "MISSING:" in front of 2 references Mike Jamesson Excel Programming 1 October 19th 05 06:33 PM
Tools | References - information about references L Mehl Excel Programming 6 July 4th 04 06:28 PM


All times are GMT +1. The time now is 12:56 PM.

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

About Us

"It's about Microsoft Excel"