Results 1 to 3 of 3

Code, that disables save, save as and close commands

Threaded View

  1. #1
    Registered User
    Join Date
    10-30-2009
    Location
    Europe
    MS-Off Ver
    Excel 2003
    Posts
    9

    Code, that disables save, save as and close commands

    Each of the worksheets in my model use A1 as a control cell for any errors and inconsistencies. My aim is to disable save and close commands in case A1 is not equal to 0 in any of the worksheets.

    The code I currently use for that purpose is as follows.

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
    Dim Rng As Range
    Dim ws As Worksheet
    
    For Each ws In Worksheets
    Set Rng = ws.Range("A1")
    
    If ws.Range > 0 Then
    Cancel = True
    lReply = MsgBox("Please correct...", vbOKOnly)
    
    End If
    End Sub
    Something however is not OK and it gives errors. Furthermore, the disabling of close command is not covered.

    Please help me update it.
    Last edited by mgmetev; 11-02-2009 at 06:32 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1