Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Solver reference problem

I am using a workbook with VBA code referring to the Excel solver. When I
transfer the workbook to a different PC, I may get problems as the reference
may get broken due to a different location of the solver.xla file. Is there
a way to handle this without involving the user of the workbook ? I have
added the following code:

solverpath = Application.Librarypath & "\solver\solver.xla"
ThisWorkbook.VBProject.References.AddFromFile solverpath

This gives a problem since the solver is already referenced initially.
Somehow, I have to dereference the solver first and then follow the above
instructions, but I don't know how. I tried with
ThisWorkbook.VBProject.References.Remove (xxx) but do not know how to code
xxx ?

Any ideas,

Martien
PS I am using Excel 97.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Solver reference problem

Recently posted by Dana DeLouis

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

--
Regards,
Tom Ogilvy


"Martien Janssen" wrote in message
...
I am using a workbook with VBA code referring to the Excel solver. When I
transfer the workbook to a different PC, I may get problems as the

reference
may get broken due to a different location of the solver.xla file. Is

there
a way to handle this without involving the user of the workbook ? I have
added the following code:

solverpath = Application.Librarypath & "\solver\solver.xla"
ThisWorkbook.VBProject.References.AddFromFile solverpath

This gives a problem since the solver is already referenced initially.
Somehow, I have to dereference the solver first and then follow the above
instructions, but I don't know how. I tried with
ThisWorkbook.VBProject.References.Remove (xxx) but do not know how to code
xxx ?

Any ideas,

Martien
PS I am using Excel 97.





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Solver reference problem

Dear Tom (and Dana)

Many thanks, I have had this problem for a long time now in different
applications and this solution seems to work well,

Thanks again,
Martien

"Tom Ogilvy" wrote in message
...
Recently posted by Dana DeLouis

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

--
Regards,
Tom Ogilvy


"Martien Janssen" wrote in message
...
I am using a workbook with VBA code referring to the Excel solver. When

I
transfer the workbook to a different PC, I may get problems as the

reference
may get broken due to a different location of the solver.xla file. Is

there
a way to handle this without involving the user of the workbook ? I have
added the following code:

solverpath = Application.Librarypath & "\solver\solver.xla"
ThisWorkbook.VBProject.References.AddFromFile solverpath

This gives a problem since the solver is already referenced initially.
Somehow, I have to dereference the solver first and then follow the

above
instructions, but I don't know how. I tried with
ThisWorkbook.VBProject.References.Remove (xxx) but do not know how to

code
xxx ?

Any ideas,

Martien
PS I am using Excel 97.







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 problem Alexey[_2_] Excel Worksheet Functions 4 March 21st 08 09:05 AM
Interesting Solver problem (Solver encounters an error) MrShorty Excel Discussion (Misc queries) 3 December 22nd 05 10:52 PM
Solver problem nj125 Excel Discussion (Misc queries) 2 May 19th 05 05:19 AM
VBA code to add a reference to solver Tbeek[_3_] Excel Programming 5 April 7th 04 04:46 PM
access the solver reference library CAB[_2_] Excel Programming 2 December 15th 03 07:30 PM


All times are GMT +1. The time now is 07:27 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"