Results 1 to 20 of 25

Thread: Solved: Prompt to save on close (askes if already saved?)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    VBAX Expert mperrah's Avatar
    Joined
    Mar 2005
    Posts
    744
    Location

    Like this?

    [vba]Private Sub Workbook_Open()
    Dim Sheet As Worksheet
    'make all sheets visible
    For Each Sheet In Worksheets
    If Sheet.Name <> "Prompt" Then
    Sheet.Visible = xlSheetVisible
    End If
    Next Sheet
    'hide the prompt
    Sheets("Prompt").Visible = xlSheetVeryHidden
    'clean up
    Set Sheet = Nothing
    End Sub
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    With Sheets("Prompt")
    'make prompt sheet visible
    Dim Sheet As Worksheet
    .Visible = xlSheetVisible
    'hide all other sheets
    For Each Sheet In Worksheets
    If Sheet.Name <> "Prompt" Then
    Sheet.Visible = xlSheetVeryHidden
    End If
    Next Sheet
    'clean up
    Set Sheet = Nothing
    End With
    ActiveWorkbook.Save
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    End Sub [/vba]

    Problem here is it saves changes without asking on close
    It should ask only if not saved, and ignore if already saved
    (running macro to hide sheets for both - yeah!)
    Last edited by mperrah; 07-20-2007 at 01:18 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •