No Macro Function to Access Solver Dialog Box (116340)



The information in this article applies to:

  • Microsoft Excel for Windows 95
  • Microsoft Excel for Windows 5.0
  • Microsoft Excel for Windows 4.0
  • Microsoft Excel for the Macintosh 5.0
  • Microsoft Excel for the Macintosh 4.0

This article was previously published under Q116340

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. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements.

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").


Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbhowto kbProgramming KB116340