Consulting

Results 1 to 4 of 4

Thread: Any way to prevent users from saving the file?

  1. #1
    VBAX Regular
    Joined
    Sep 2008
    Posts
    23
    Location

    Exclamation Any way to prevent users from saving the file?

    Hi,

    I am currently preparing my company's budget and would require a macro for my budget templates. I will actually need a macro to check a sum of ranges to make sure it is not above a certain amount.

    For example

    Row B12 - Total Staff Cost - Maximum cap = $50K
    Row B15 - Total G&A Cost - Maximum cap = $10K

    Is there a way to stop the user from saving the file if the amount they have keyed in the summary file exceeds the budget guideline given?

    Thanks.. Your help will be greatly appreciated!

  2. #2
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    You could put your check in the BeforeSave Event of the workbook.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  3. #3
    VBAX Regular
    Joined
    Sep 2008
    Posts
    23
    Location
    How do i place this BeforeSave Event ?

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Like this.
    [VBA]Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    With Sheets(1)
    If .Range("B12") > 50000 Or .Range("B15") > 10000 Then
    Cancel = True
    MsgBox "Not saved - Limits exceeded", vbCritical
    End If
    End With
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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