Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
BeforeSave Problem | Excel Programming | |||
BeforeSave Event Question | Excel Programming | |||
beforesave and beforeclose | Excel Programming | |||
BeforeSave Sub | Excel Programming | |||
VBA - BeforeSave - NEED HELP | Excel Programming |