Automatically save workbook when exiting

  • Thread starter Thread starter Maddoktor
  • Start date Start date
M

Maddoktor

Hi all,

I have created a workbook that records the user name, date and time the
workbook was opened in a hidden worksheet, but as it is updated it asks
the user whether to save the workbook of the changes or not before exiting.

I would like the workbook to automatically save ONLY the hidden
worksheet without offering an option to the user. If the user has
modified any other worksheets of the workbook then I would like to
follow the protocol of asking the user to save the complete workbook. At
all times, the hidden worksheet must be save without question every time
the workbook is exited.

Is this possible?

Thanx in advance

Maddoktor
 
Hi Maddoktor,

Since you record this information when the workbook is opened, I assume the
code is fired in the Workbook_Open event. To save the file after the hidden
sheet is updated, insert this line:

ThisWorkbook.Save

immediately after the code that enters the info.

Regards,
GS
 
GS said:
Hi Maddoktor,

Since you record this information when the workbook is opened, I assume the
code is fired in the Workbook_Open event. To save the file after the hidden
sheet is updated, insert this line:

ThisWorkbook.Save

immediately after the code that enters the info.

Regards,
GS

Hey ... thanx it worked but I have one little problem. The user name and
date/time keeps being recorded in cells A1 and B1 and every time it
saves it overwrites the previous information. Would you happen to know
the coding so that when the information is first recorded in cells A1
and B1, before saving the active cells then become A2 and B2. Therefore,
the next time the workbook is opened, the information will be recorded
in A2 and B2.

Thanx again in advance.
 

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