View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
R A R A is offline
external usenet poster
 
Posts: 3
Default Force worksheet to NOT save

Hello

I have a frustrating situation, which several kind ppl have already
provided their input (thankyou).
However, I was wondering if someone might be able to examine the code
below, and tell me why when I exit a workbook running macros it still
asks me if I want to save? My goal is for this NOT to happen.
-----------------------------------------------------------
Sub workbook_before_close()
Worksheets("Error").Visible = xlSheetVisible
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Visible = (ws.Name < "Error") * -1 - 1
Next ws
Application.DisplayAlerts = False
Application.SaveWorkspace
Application.DisplayAlerts = True
End Sub
-----------------------------------------------------------
Sub workbook_open()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Visible = xlSheetVisible
Next ws
Worksheets("Error").Visible = xlVeryHidden
Application.Sheets("Sheet1").Select
If Now = Worksheets("Error").Range("AO241") Then
Confirm = MsgBox("This workbook has expired. Please contact support
for further assistance.", vbInformation + vbOKOnly, "Workbook Expiry")
If Confirm = vbOKOnly Then
Application.Quit
Else: Application.Quit
End If
End If
ThisWorkbook.Saved = True
Application.DisplayAlerts = False
End Sub
-----------------------------------------------------------
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
MsgBox "Sorry, but the save functions of this workbook have been
disabled."
Cancel = True
End Sub
-----------------------------------------------------------

Thanks again for your help.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!