P
puba
The following code aims to allow data input into the spreadsheet, and
then close it as soon as possible, rather than keeping it open, so that
others can also input data.
When opening the workbook, you get a warning message that you should
aim to close it within 10 minutes.
Then, 10 minutes later, you get a message box suggesting to exit ans
save the workbook.
All this works fine.
PROBLEM
If you close the workbook in less than 10 minutes, the workbook reopens
itself to display the warning "Please exit database if not in use."
This is really silly because the operator did the right thing to close
the book promptly, and now the book is open again...
QUESTION
Can I make the macro conditional (to run only if the workbook is still
open)?
Thanks,
Puba
-----------------------------------------
Sub autpen()
MsgBox "You will get a prompt for saving and exiting the file after 10
minutes."
Application.OnTime Now + TimeValue("00:10:00"), "autoclose"
End Sub
-------------------------------------
Sub autoclose()
MsgBox "Please exit database if not in use." & Chr(13) & "..." &
Chr(13) & "Click Cancel in following screen to remain in the helpdesk
database, you will not get another prompt."
' closes the active workbook and lets the user decide if
' changes are to be saved or not
ActiveWorkbook.Close
End Sub
---------------------------------
then close it as soon as possible, rather than keeping it open, so that
others can also input data.
When opening the workbook, you get a warning message that you should
aim to close it within 10 minutes.
Then, 10 minutes later, you get a message box suggesting to exit ans
save the workbook.
All this works fine.
PROBLEM
If you close the workbook in less than 10 minutes, the workbook reopens
itself to display the warning "Please exit database if not in use."
This is really silly because the operator did the right thing to close
the book promptly, and now the book is open again...
QUESTION
Can I make the macro conditional (to run only if the workbook is still
open)?
Thanks,
Puba
-----------------------------------------
Sub autpen()
MsgBox "You will get a prompt for saving and exiting the file after 10
minutes."
Application.OnTime Now + TimeValue("00:10:00"), "autoclose"
End Sub
-------------------------------------
Sub autoclose()
MsgBox "Please exit database if not in use." & Chr(13) & "..." &
Chr(13) & "Click Cancel in following screen to remain in the helpdesk
database, you will not get another prompt."
' closes the active workbook and lets the user decide if
' changes are to be saved or not
ActiveWorkbook.Close
End Sub
---------------------------------