Closing excel and saving workbooks

  • Thread starter Thread starter Hari
  • Start date Start date
H

Hari

Hi,

I opened a new session of excel and kept the personal macro file unhidden.
Then I opened a new worksheet book1.

In VB I inserted a module in Book 1.

Then I wrote this code.

Surprsingly, excel saved book 1 in my Xlstart folder along with the personal
macro workbook. ( I had not saved Book 1)

Sub closingexcel()
Application.DisplayAlerts = False
Application.Quit
Workbooks("book1").Save
Workbooks("personal").Save
End Sub

Regards,
Hari
India
 
Hi
you should try to first save the files and the quit the application.
Also Excel saves the file in the current directory. So you may change
the directory first in your macro
 
Hi Frank,

I was doing a test to understand whether excel saves the files if I write
application.quit before writing the save workbooks statements.

I was surprised that excel continues to exceute statement even after it
encounters quit statement. ( That is it saved my Book 1). I still dont
understand this aspect completely.

Also, I was surprised that Excel saved my book1 which was a new workbook and
usually if we press on save button on new workbooks it prompts for the
location ( and the default location is My Documents for my excel 2002) so I
expected excel to save the file in My documents if at all the file is saved.
Rather excel saved it in xlstart folder. U say that I shud change the
directory. But, how is it that when Im working on a completely new excel
session with no other macros run in it the VB remembers or considers the
default location to be xlstart folder.

Please elaborate if possible.

Regards,
Hari
India
 

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