#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Autosaving

To cut a long story short...

I've got a spreadsheet that will be ran automatically.
The spreadsheet opens, does some calculations and then is
supposed to save with the file name being the date of the
first day of that month. This is just a monthly report.

I'm receiving a problem however trying to close and save
the spreadsheet from within the code. Below is the code
I'm using when closing the spreadsheet.

Private Sub Workbook_BeforeClose(Cancel As Boolean)

If Not done Then
MsgBox filename 'just verifying the name is being passed
through, which it is.

ActiveWorkbook.SaveAs ("C:\MonthlyReport\" & filename)
End If

End Sub

Now this code works should I close the spreadsheet
myself, manually, within Excel. However, should I use the
line...

ThisWorkbook.Close

The spreadsheet prompts me with the

"Would you like to save changes to Monthly Report.xls"

And on clicking Yes/No... does not appear to run:

ActiveWorkbook.SaveAs ("C:\MonthlyReport\" & filename)

any more, the report for that month is not saved.

Anyone have any ideas why this might be occuring? Thanks.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autosaving an Excel Workbooks as versions Doctorjones_md Excel Discussion (Misc queries) 2 December 18th 06 08:09 PM
Can Excel 2003 prompt before Autosaving? Chris777 Excel Discussion (Misc queries) 1 April 19th 05 12:08 AM
Problems Autosaving an excel file/sheet as Text MaxFrance Excel Discussion (Misc queries) 0 March 25th 05 09:49 AM
Autosaving Workbook Microsoft Excel Programming 6 January 8th 04 01:59 PM


All times are GMT +1. The time now is 03:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"