Now, let's add code to the save button:Private Sub cmdSave_click()
If objDoc is nothing then
msgbox "Application not running"
else
objdoc.Save
End if
End sub
We check whether the application is running or not. If it's running then we save the document otherwise we display a message telling the user that the application is not running.
Private Sub cmdClose-Click()
If objDoc is nothing then
MsgBox"Application not running"
else
objApp.Quit
Set objDoc=Nothing
Set objApp=Nothing
End if
End Sub
We check if the application is running or not. If it's running we close the application using the "Quit" method of the "Application" class. Note it's important to remove the application from the memory. The following lines remove the objects from the memory:
Set objDoc=Nothing
Set objApp=Nothing
Private Sub cmdExit_Click()
If objdoc is nothing then
Unload me
Else
MsgBox "Please close application first"
End If
End Sub
Unload the open form and use the "End" command to destroy instance of the application. That's it!
Comments