No Macro Function to Access Solver Dialog Box

Last reviewed: December 1, 1997
Article ID: Q116340
The information in this article applies to:
  • Microsoft Excel for Windows, versions 4.0, 5.0
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Excel for the Macintosh, versions 4.0, 5.0

SUMMARY

The Solver add-in macro that ships with Microsoft Excel does not provide a macro function to display the main Solver dialog box. However, you can display this dialog box using the Run() macro command or the Run method in a Visual Basic for Applications procedure.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

Visual Basic for Applications Example

The following is an example using Visual Basic, Applications Edition:

   ' Macro to call Solver main dialog box.
   Sub MainSolverDialog()

       ' Turn error checking off.
       On Error Resume Next

       ' Test if Solver add-in is already open.
       If Application.IsNA(Workbooks("Solver.xla").Name) Then
           ' If add-in is not open, then open Solver.xla.
           ' NOTE: You may need to adjust the path to Solver.xla. 
           ' For example, the path may be 
           ' C:\MSOffice\Excel\Library\Solver\Solver.xla.
           Workbooks.Open ("C:\Excel\Library\Solver\Solver.xla")
           ' Run Solver auto open macro to load add-in.
           Application.Run ("Solver.xla!Auto_Open")
       ' Ends the If statement.
       End If

       ' Turn error checking back on.
       On Error GoTo 0
       ' Run the Solver macro to display the main Solver dialog box.
       Application.Run ("Solver.xla!Do_Main")

   ' End the macro.
   End Sub

NOTE: You may need to adjust the path to Solver.xla.

Microsoft Excel 4.0 and 4.0a for Windows

   A1: Solver Main Dialog
   A2: =IF(AND(ISNA(DOCUMENTS(2,"SOLVER.XLA"))))
   A3: =OPEN("C:\EXCEL\LIBRARY\SOLVER\SOLVER.XLA")
   A4: =Run("Solver.xla!Auto_Open")
   A5: =END.IF()
   A6: =RUN("SOLVER.XLA!Do_Main")
   A7: =RETURN()

   Description of macro:

   A1: Name of macro.
   A2: Check to see if Solver is already opened.
   A3: If Solver is not open, open it.
   A4: Run Solver's auto open macro to load the add-in.
   A5: End the If function in A2.
   A6: Run the 'Do_Main' macro in the Solver add-in.
   A7: End the macro.

Microsoft Excel 4.0 for the Macintosh

   For the above macro to work with Microsoft Excel for the Macintosh,
   replace the MS-DOS style file name with the appropriate Macintosh style
   file name (for example, "Macintosh HD: Microsoft Excel: Macro Library:
   Solver: Solver Add-In").


Additional query words: 4.00 4.0a 5.00xlm kbmacro
Keywords : kbcode kbprg kbtool PgmHowto
Version : WINDOWS:4.0,5.0,5.0c,7.0; MACINTOSH:4.0,5.0
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 1, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.