LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to call SolverSolve portably for Excel XP and Excel 2000

My VBA macro calls Solver.Solve, which requires the code
to reference solver.xla. Unfortunately, the location of
solver.xla is different for Office 2000 (C:\Program
Files\Microsoft Office\Office\Library\Solver) than Office
XP (C:\Program Files\Microsoft Office\Office10
\Library\Solver).

Thus, if I set the reference (using the Visual Studio 6
IDE menuitem "Tools" "References...") for Office XP,
then the macro fails on Office 2000, and visa versa.

How can I create a single version of my macro that
automatically references the proper location of
solver.xla so it can call SolverSolve?

I have tried the following approaches so far (without
success)...

1. Application.VBE.ActiveVBProject.References.AddFrom File
Application.LibraryPath & "\Solver\Solver.xla"

This approach ALMOST works, but it requires the user to
lower their security settings for macros (allowing self-
referential code), which is a major downside in today's
world of macro viruses. Also, it sometimes fails with a
namespace conflict, even though solver.xla is not active.

2. status = Application.Run("SolverSolve", True)
instead of:
status = SolverSolve(UserFinish:=True)

Using Application.Run() doesn't solve the problem... the
call still fails unless the reference is set.

3. Set obj = CreateObject("Excel.Solver")
or: Set obj = CreateObject("Excel.Solve")
or: Set obj = GetObject(,"Excel.Solver")
or: Set obj = GetObject(Application.LibraryPath
& "\Solver\Solver.xla")
etc. etc. etc.

I have not been able to find a proper incantation of
CreateObject() or GetObject() parameters that return an
object in which I can invoke the SolverSolve
function/method.

I even tried a few zanier things to no avail.

Please help! How can I write portable code that calls
SolverSolve and works with BOTH Excel XP and Excel 2000
(without requiring my macro code file to be copied into
the same directory as solver.xla)?

Any assistance is greatly appreciated.
Chris Russell

 
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
Open 2000 file attachments in Excel 2000 Judy[_2_] Excel Discussion (Misc queries) 2 September 20th 07 10:20 PM
I cannot edit cell format in Excel 2000 (Part of office 2000)! Brett Excel Discussion (Misc queries) 1 April 12th 06 05:58 PM
Using Excel 2000 as Data source for Word 2000 document Malcolm Agingwell Excel Discussion (Misc queries) 2 June 21st 05 09:28 AM
Hyperlink in Excel 2000 can't open bookmarked Word 2000 file DCheslock Excel Discussion (Misc queries) 1 May 5th 05 10:46 PM
Excel Programs developed in Office 2000 on Windows 2000 Trooper Excel Discussion (Misc queries) 4 March 12th 05 11:09 PM


All times are GMT +1. The time now is 02:07 PM.

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

About Us

"It's about Microsoft Excel"