View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ture Magnusson Ture Magnusson is offline
external usenet poster
 
Posts: 21
Default Saving And Checking

Bigjayce

Of course it's easy. Use the fact that the workbook's Saved
property is set to True when the workbook is saved.

Sub SaveWorkbook()
Dim x As Boolean

x = ThisWorkbook.Saved
ThisWorkbook.Saved = False
Application.Dialogs(xlDialogSaveAs).Show

If ThisWorkbook.Saved = True Then
MsgBox "It's been saved"
Else
MsgBox "No save"
ThisWorkbook.Saved = x
End If
End Sub

--
Ture Magnusson
Microsoft MVP - Excel
Karlstad, Sweden

"Bigjayce" wrote in message
...

Hi there,

I am writing a save and close button and this must be so easy I have
tied myself in knots and cannot see what is wrong.

Basically I have created the button and am using the
Application.Dialogs(xlDialogSaveAs).Show command to bring up the save
file box. after the filename is entered and the file saves the
Application.quit is activated and the spreadsheet closes.

Problem is, if you click the CANCEL button the spreadsheet still quits
so I need a way of checking to see if the spreadsheet has been saved
and if not returning to the workbook, if it has been saved then quit.

Must be easy to do lol

I'm using Excel 97

Bigjayce


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/