Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Close & Saving Problems 1

Status
Not open for further replies.

Firery

Technical User
Sep 23, 2003
18
AU
I have a few Excel Spread sheets projects with their own Auto_Close modules. The modules make the toolbars visible and a few other things as well as 'ActiveWorkbook.Save' to ensure any changes are saved.
Problem - If I have more than one project open, and close one, the Auto_Close for the other project runs as well leading to a runtime error.
How can I prevent the Auto_Close on the other project from running.
It actually seems to be running the other Auto_Close first.

Second problem - 'ActiveWorkbook.Save'
Is this sufficient to ensure that the workbook will be saved with any changes, I have had reports from my users who have returned to the program to find that information entered previously is missing, which can only mean that the program did not save the changes.
Which is the best way to ensure that a workbook is saved no matter how it is closed.(without prompting the user)

Thanks to all who can help.
 
1. Auto_Close is there to be backward compatible with earlier Excel versions. You should be using
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
in the ThisWorkbook code module.

2. ActiveWorkbook.Save is OK. It forces a save of the current state as you wish. An alternative is
Code:
ActiveWorkbook.Close savechanges:=True



Regards
BrianB
Use CupOfCoffee to speed up all windows applications.
It is easy until you know how.
================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top