Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Saving And Checking


Hi there,

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

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

Problem is, if you click the CANCEL button the spreadsheet still quit
so I need a way of checking to see if the spreadsheet has been save
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

Bigjayc

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Saving And Checking

Instead of using the Dialogs(xlDialogSaveAs) method, use
Application.GetSaveAsFilename. Test the result of this, and if not False,
save and close the file. Note that GetSaveAsFilename doesn't actually save
the file -- it merely prompts the user for a file name.

Dim FName As Variant
FName = Application.GetSaveAsFilename(, "Excel Files (*.xls),*.xls")
If FName < False Then
ThisWorkbook.SaveAs FName
Application.Quit
Else
' user cancelled, do nothing
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"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/



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


Thanks guys :)

I knew it wasn't difficult but I just got to the point where I couldn'
see the code anymore it was just funny dots on the screen lol

Bigjayc

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Saving And Checking

You are welcome, Bigjayce!

--
Ture Magnusson
Microsoft MVP - Excel
Karlstad, Sweden

"Bigjayce" wrote in message
...

Thanks guys :)

I knew it wasn't difficult but I just got to the point where I couldn't
see the code anymore it was just funny dots on the screen lol

Bigjayce


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



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
Automaticly saving formula's to values when saving Gunti Excel Discussion (Misc queries) 8 November 11th 08 09:34 AM
Spell Checking with checking cell notes jfitzpat Excel Discussion (Misc queries) 0 August 8th 07 10:26 PM
Checking and IF ? mohamadhafiz Excel Worksheet Functions 5 June 26th 07 11:04 PM
Day Checking K1KKKA Excel Discussion (Misc queries) 4 January 30th 07 08:19 PM
Add checking Pat Excel Worksheet Functions 5 December 17th 04 08:25 PM


All times are GMT +1. The time now is 08:54 PM.

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

About Us

"It's about Microsoft Excel"