J
justin.arnold2
I'm in the process of automating a workbook for an engineer at our
site. He has a macro written to run some calculations in Excel using
solver.xla and send these values to another server. As it stands now
the macro is accessed by a button on one of the worksheets in the
workbook. What I have been asked to do is setup a scheduled task that
runs every three hours. This task will open the workbook, launch the
macro that writes data to the other server, and then close the
workbook and quit Excel. I have setup the following code on the
Workbook_Open sub:
Private Sub Workbook_Open()
'Call Module5.Run_solver
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.Quit
End Sub
This code works as stated except that the application does not close.
Excel stays open but the workbook closes. I have tried to reverse the
order of the ActiveWorkbook.Close and Application.Quit but the result
is the same. Module5.Run_solver is the macro that was designed by the
engineer. Below is the code for the macro:
Sub Run_solver()
'
' Run_solver Macro
' Macro recorded 5/22/2008 by ****** *******
'
Application.Run "Solver.xla!Autpen"
SolverReset
'SolverOk SetCell:="$O$7", MaxMinVal:=3, ValueOf:="0",
ByChange:="$M$9"
SolverOptions Precision:=0.01, Convergence:=0.1
SolverOk SetCell:="$O$7", MaxMinVal:=3, ValueOf:="0", ByChange:="$M
$9"
SolverSolve True
SolverReset
'SolverOk SetCell:="$O$8", MaxMinVal:=3, ValueOf:="0",
ByChange:="$L$9"
SolverOptions Precision:=0.01, Convergence:=0.1
SolverOk SetCell:="$O$8", MaxMinVal:=3, ValueOf:="0", ByChange:="$L
$9"
SolverSolve True
SolverReset
'SolverOk SetCell:="$O$16", MaxMinVal:=3, ValueOf:="0",
ByChange:="$M$18"
SolverOptions Precision:=0.01, Convergence:=0.1
SolverOk SetCell:="$O$16", MaxMinVal:=3, ValueOf:="0",
ByChange:="$M$18"
SolverSolve True
SolverReset
'SolverOk SetCell:="$O$17", MaxMinVal:=3, ValueOf:="0",
ByChange:="$L$18"
SolverOptions Precision:=0.01, Convergence:=0.1
SolverOk SetCell:="$O$17", MaxMinVal:=3, ValueOf:="0",
ByChange:="$L$18"
SolverSolve True
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M37").Text, _
Application.ActiveSheet.Range("S12"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N37"))
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M38").Text, _
Application.ActiveSheet.Range("R12"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N38"))
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M39").Text, _
Application.ActiveSheet.Range("L14"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N39"))
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M40").Text, _
Application.ActiveSheet.Range("L23"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N40"))
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M41").Text, _
Application.ActiveSheet.Range("M14"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N41"))
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M42").Text, _
Application.ActiveSheet.Range("M23"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N42"))
End Sub
I've seached many resources online and I've tried many different
things but I cannot seem to figure out why Excel will not respond to
the Application.Quit command. Is it possible that I need to close
solver.xla before Excel can be completely closed out? Also, I am
running Excel 2003 with SP3 and all Microsoft security updates and
patches. Any help on this at all would be greatly appreciated. Thanks
J A
site. He has a macro written to run some calculations in Excel using
solver.xla and send these values to another server. As it stands now
the macro is accessed by a button on one of the worksheets in the
workbook. What I have been asked to do is setup a scheduled task that
runs every three hours. This task will open the workbook, launch the
macro that writes data to the other server, and then close the
workbook and quit Excel. I have setup the following code on the
Workbook_Open sub:
Private Sub Workbook_Open()
'Call Module5.Run_solver
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.Quit
End Sub
This code works as stated except that the application does not close.
Excel stays open but the workbook closes. I have tried to reverse the
order of the ActiveWorkbook.Close and Application.Quit but the result
is the same. Module5.Run_solver is the macro that was designed by the
engineer. Below is the code for the macro:
Sub Run_solver()
'
' Run_solver Macro
' Macro recorded 5/22/2008 by ****** *******
'
Application.Run "Solver.xla!Autpen"
SolverReset
'SolverOk SetCell:="$O$7", MaxMinVal:=3, ValueOf:="0",
ByChange:="$M$9"
SolverOptions Precision:=0.01, Convergence:=0.1
SolverOk SetCell:="$O$7", MaxMinVal:=3, ValueOf:="0", ByChange:="$M
$9"
SolverSolve True
SolverReset
'SolverOk SetCell:="$O$8", MaxMinVal:=3, ValueOf:="0",
ByChange:="$L$9"
SolverOptions Precision:=0.01, Convergence:=0.1
SolverOk SetCell:="$O$8", MaxMinVal:=3, ValueOf:="0", ByChange:="$L
$9"
SolverSolve True
SolverReset
'SolverOk SetCell:="$O$16", MaxMinVal:=3, ValueOf:="0",
ByChange:="$M$18"
SolverOptions Precision:=0.01, Convergence:=0.1
SolverOk SetCell:="$O$16", MaxMinVal:=3, ValueOf:="0",
ByChange:="$M$18"
SolverSolve True
SolverReset
'SolverOk SetCell:="$O$17", MaxMinVal:=3, ValueOf:="0",
ByChange:="$L$18"
SolverOptions Precision:=0.01, Convergence:=0.1
SolverOk SetCell:="$O$17", MaxMinVal:=3, ValueOf:="0",
ByChange:="$L$18"
SolverSolve True
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M37").Text, _
Application.ActiveSheet.Range("S12"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N37"))
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M38").Text, _
Application.ActiveSheet.Range("R12"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N38"))
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M39").Text, _
Application.ActiveSheet.Range("L14"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N39"))
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M40").Text, _
Application.ActiveSheet.Range("L23"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N40"))
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M41").Text, _
Application.ActiveSheet.Range("M14"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N41"))
macroResult = Application.Run("PIPutValx", _
Application.ActiveSheet.Range("M42").Text, _
Application.ActiveSheet.Range("M23"), _
Application.ActiveSheet.Range("H2").Value, , _
Application.ActiveSheet.Range("N42"))
End Sub
I've seached many resources online and I've tried many different
things but I cannot seem to figure out why Excel will not respond to
the Application.Quit command. Is it possible that I need to close
solver.xla before Excel can be completely closed out? Also, I am
running Excel 2003 with SP3 and all Microsoft security updates and
patches. Any help on this at all would be greatly appreciated. Thanks
J A