Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code to add a reference to solver

I what a piece of VBA code that will add a reference to solver.
I would put it in a sub or function that uses solver

Thank

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA code to add a reference to solver

http://support.microsoft.com/?id=160647
XL97: How to Programmatically Create a Reference

--
Regards,
Tom Ogilvy

"Tbeek " wrote in message
...
I what a piece of VBA code that will add a reference to solver.
I would put it in a sub or function that uses solver

Thanks


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code to add a reference to solver

I would like to create the reference to solver in VBA that would b
equivalent to:
From the Visual Basic Editor, Tools, References, CheckMark Solver
click OK.

I am making a function that uses solver and I want to distribute it t
my colleagues but I don't want to have to go to their pc and tur
solver on and reference it. I would like the function to do it befor
it calls solver.
If there was a good way to check that solver was installed an
referenced, I could also use that so the function wouldn't have t
install and reference solver every time the function was used in
worksheet

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default VBA code to add a reference to solver

Sub SolverInstall()
On Error Resume Next
Dim wb As Workbook
Dim SolverPath As String

' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

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

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

'Solver itself has 'focus' at this point.
'Make sure you point to the correct Workbook for Solver
wb.VBProject.References.AddFromFile SolverPath
End Sub

HTH. :)
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Tbeek " wrote in message
...
I what a piece of VBA code that will add a reference to solver.
I would put it in a sub or function that uses solver

Thanks


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA code to add a reference to solver

Read the article - it tells you how to create a reference programmatically.
Knowing that, you should be able to adapt it to create a specific reference
for solver. Giving a dick and jane explantion of what you want to do is
unnecessary as you already stated what you wanted to do in your original
question. Using the information in the article would also give you the
insights to determine if the reference already exists. You would just loop
through the references collection and test if any of the references are for
solver (and that if so, it isn't broken).

--
Regards,
Tom Ogilvy

"Tbeek " wrote in message
...
I would like to create the reference to solver in VBA that would be
equivalent to:
From the Visual Basic Editor, Tools, References, CheckMark Solver,
click OK.

I am making a function that uses solver and I want to distribute it to
my colleagues but I don't want to have to go to their pc and turn
solver on and reference it. I would like the function to do it before
it calls solver.
If there was a good way to check that solver was installed and
referenced, I could also use that so the function wouldn't have to
install and reference solver every time the function was used in a
worksheet.


---
Message posted from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default VBA code to add a reference to solver

You may prefer this other version that I use. HTH. :)

Sub SolverInstall()
'// Dana DeLouis
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


--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Dana DeLouis" wrote in message
...
Sub SolverInstall()
On Error Resume Next
Dim wb As Workbook
Dim SolverPath As String

' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

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

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

'Solver itself has 'focus' at this point.
'Make sure you point to the correct Workbook for Solver
wb.VBProject.References.AddFromFile SolverPath
End Sub

HTH. :)
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Tbeek " wrote in message
...
I what a piece of VBA code that will add a reference to solver.
I would put it in a sub or function that uses solver

Thanks


---
Message posted from http://www.ExcelForum.com/





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
Solver formula "Equal to Value of:" cell reference ORLANDO VAZQUEZ[_2_] Excel Discussion (Misc queries) 2 March 24th 09 09:42 PM
Interesting Solver problem (Solver encounters an error) MrShorty Excel Discussion (Misc queries) 3 December 22nd 05 10:52 PM
Solver code does not save results to sheet - What am I missing?! Simon Livings Excel Programming 0 January 16th 04 03:55 PM
access the solver reference library CAB[_2_] Excel Programming 2 December 15th 03 07:30 PM
Reference a Column in Code Wally Steadman[_3_] Excel Programming 1 November 17th 03 11:26 AM


All times are GMT +1. The time now is 04:29 AM.

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"