AppClose (statement)

Syntax AppClose [name$]
Description Closes the named application.
Comments The name$ parameter is a String containing the name of the application. If the name$ parameter is absent, then the AppClose statement closes the active application.
Example This example activates Excel, then closes it.
Sub Main()
  If AppFind$("Microsoft Excel") = "" Then 'Make sure Excel is there.
    MsgBox "Excel is not running."
    Exit Sub
  End If
  AppActivate "Microsoft Excel"       'Activate it (unnecessary).
  AppClose "Microsoft Excel"         'Close it.
End Sub 
See Also AppMaximize (statement); AppMinimize (statement); AppRestore (statement); AppMove (statement); AppSize (statement).
Notes A runtime error results if the application being closed is not enabled, as is the case if that application is currently displaying a modal dialog box. The name$ parameter is the exact string appearing in the title bar of the named application's main window. If no application is found whose title exactly matches name$, then a second search is performed for applications whose title string begins with name$. If more than one application is found that matches name$, then the first application encountered is used.