Closing Excel w/o Error message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an Excel workbook that uses forms for data entry. An EXIT command is
built into the entry forms which closes the workbook fine. My problem is
that the entry forms can be closed (hidden) to allow te users to navigate
through the different sheets to review data and/or print. If a user clicks
on the Window actions in the Upper Right (X) or through File / Exit and not
through the entry form the application returns the "Micsoft Excel has
encountered a problem" error message.

What is the best way to eliminate this error in Code and where in the code?
In the Entry Form code or This Workbook?

Thanks...
 
I am not sure exactly what you are trying to do, but I think you should be
able to deal with this by handling the "Workbook_BeforeClose" event in the
ThisWorkbook code module.
 
Lucas, thanks for the tip. Put me on the right path. Used the following code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
' Close Entry form before closing workbook
Cancel = True
MsgBox "You must Select Exit from the Entry Panel"
frmEntry.Show

End Sub
 
Glad that I could help.

The Hawk said:
Lucas, thanks for the tip. Put me on the right path. Used the following code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
' Close Entry form before closing workbook
Cancel = True
MsgBox "You must Select Exit from the Entry Panel"
frmEntry.Show

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top