PDA

View Full Version : Solved: User can only save workbook if completed, or close without saving



SiChambo
05-08-2013, 06:05 AM
I have found a fantastic fix (that was developed by Lucas)), that lets me resolve 85% of an issue I have been presented with, with the ID ref no as id=587. See article

vbaexpress.com/kb/getarticle.php?kb_id=587

My question is how do I close this work book without saving?
What I mean is, should the user not have all the detail in front of them to complete the work sheet then prevent them from saving the work book partially complete, and give them the option to either proceed and complete the sheet in full before saving or exit without saving?

At present I can open it but cannot close it at all without completing it, which worries me as the user will just put anything in the mandated cells just to get it off his screen.

Please advise

I am learning fast with VBA but not fast enough

SamT
05-08-2013, 07:31 AM
To allow the use to close the workbook at any time, but not to save it if it is incomplete, find this section

If RngStr <> "" Then
MsgBox Prompt & RngStr, vbCritical, "Incomplete Data"
Cancel = True
Else

And change it to this
If RngStr <> "" Then
ThisWorkbook.Saved = True
Cancel = False
Else

SiChambo
05-09-2013, 01:41 AM
Sam Hi

Many Thanks, however what I would like is when the user tries to close or save the work book, for the the Message box to pop up with the cells which are not populated then give the user the option to

Cancel and continue to complete the form or
Close the workbook without saving.

When I do as you suggested it just closes without any Message prompt, so the user will not be aware that the changes have not been saved.

SiChambo
05-09-2013, 05:14 AM
Sam Hi

FYI I have solved this, Thanks for your input.

mdmackillop
05-09-2013, 05:17 AM
Please post your solution for the benefit of others.

SiChambo
06-03-2013, 12:29 AM
I have expanded on this and came across a couple of glitches, now it works like I wanted it to I will post.