LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default save and exit macro

Greetings:

I wrote a macro (below) to save a workbook to two files and exit. If
the paths are not available, the workbook should not be saved and
Excel should simply quit.

I think I may be misuing On Error Resume Next below, because the fact
that the script is not finding the path is not causing an error. Any
advice?

Again, if the path is not found, I want Excel to simply exit (after
restoring screenupdating and displayalerts). All changes are intended
to be discarded if the script is unable to locate and save to the
identified path. Thanks!

---

Sub archive_and_exit()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

On Error Resume Next
With ThisWorkbook
.SaveAs Filename:="\\test\test1" & ".xlsb"
.SaveAs Filename:="\\test\test2" & Format(Now, "mmm dd, yyyy -
hhmm AM/PM") & ".xlsb"
End With

Application.Quit
ActiveWorkbook.Close False

Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub
 
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
Save/exit macro andrewbt Excel Programming 2 August 4th 07 08:54 PM
Excel Save as & Exit macro [email protected] Excel Programming 0 July 26th 07 07:50 AM
running macro at save/close/exit Pedro Excel Programming 1 August 31st 06 07:03 PM
Write macro don't ask to save when exit excel Rui Alvares Excel Programming 0 March 29th 06 12:50 AM
Macro: Exit active workbook without save? Don Excel Worksheet Functions 0 May 20th 05 06:47 AM


All times are GMT +1. The time now is 02:59 AM.

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"