No Macro Function to Access Solver Dialog Box

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 professionals 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/overview/overview.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.0a 5.00xlm kbmacro

Keywords : kbcode kbprg kbtool PgmHowto
Version : MACINTOSH:4.0,5.0; WINDOWS:4.0,5.0,7.0
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.