Results 1 to 11 of 11

Thread: [RESOLVED] BeforeClose

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    50

    Resolved [RESOLVED] BeforeClose

    I have the following routines inThisWorkbook but althougg I can get the auto_open to work I can't get the BeforeClose to work.

    Anyone have any ideas?

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub auto_open()
    4.  
    5. For Each ws In ThisWorkbook.Worksheets
    6. If Not ws.Name = "Error" Then
    7. ws.Visible = xlSheetVisible
    8. Else
    9. End If
    10. Next ws
    11.  
    12. Worksheets("Error").Visible = xlSheetVeryHidden
    13.  
    14. End Sub
    15.  
    16. Private Sub Workbook_BeforeClose(Cancel As Boolean)
    17.  
    18. Application.EnableEvents = False
    19.  
    20. MsgBox ("Closing")
    21.  
    22. If Not ThisWorkbook.Saved Then
    23. Else
    24. Worksheets("Error").Visible = xlSheetVisible
    25. For Each ws In ThisWorkbook.Worksheets
    26. If Not ws.Name = "Error" Then
    27. ws.Visible = xlSheetVeryHidden
    28. Else
    29. ws.Visible = xlSheetVisible
    30. End If
    31. Next ws
    32. ThisWorkbook.Save
    33. End If
    34.  
    35. End Sub


    Thanks
    Last edited by si_the_geek; Apr 5th, 2006 at 05:42 AM. Reason: corrected VBCode tags

Posting Permissions

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



Click Here to Expand Forum to Full Width