LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default BeforeSave question

A couple of errors in the code. Try this version

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim sFile
Dim i As Long
Stop
Application.EnableEvents = False
Application.DisplayAlerts = False
If ThisWorkbook.FileFormat < xlTemplate Then
On Error GoTo wb_exit
Cancel = True
For i = Worksheets.Count To 2 Step -1
If Worksheets(i).Visible < xlSheetVisible Then
Worksheets(i).Delete
End If
Next i
'process last sheet
If Worksheets(1).Visible < xlSheetVisible Then
If Worksheets.Count 1 Then
Worksheets(1).Delete
Else
Worksheets.Visible = True
End If
End If
End If

If SaveAsUI Then
sFile = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If sFile < False Then
ThisWorkbook.SaveAs sFile
End If
Else
ThisWorkbook.Save
End If

wb_exit:
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"RPIJG" wrote in
message ...

anyone? I'm taking any ideas here.


--
RPIJG
------------------------------------------------------------------------
RPIJG's Profile:

http://www.excelforum.com/member.php...fo&userid=9285
View this thread: http://www.excelforum.com/showthread...hreadid=484084



 
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
BeforeSave Problem Andibevan[_4_] Excel Programming 14 August 12th 05 05:15 PM
BeforeSave Event Question Andibevan[_4_] Excel Programming 0 August 11th 05 11:35 AM
beforesave and beforeclose Adam Harding Excel Programming 2 July 25th 05 11:11 AM
BeforeSave Sub Phil Hageman[_3_] Excel Programming 6 January 14th 04 10:12 AM
VBA - BeforeSave - NEED HELP HRobertson Excel Programming 2 October 23rd 03 06:50 PM


All times are GMT +1. The time now is 05:10 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"