Results 1 to 4 of 4

Thread: Using VBA to disable Excel save function?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Using VBA to disable Excel save function?

    Is it possible to use VBA to disable the Save andSave As... functions in Excel for a particular application?

    I was thinking of something like this, placed in the ThisWorkbook VBA module:

    Code:
    On ApplicationSave
        MsgBox "Application cannot be saved"
    Close Workbook
    I am not sure of the exact syntax but basically that describles what I want to do. Would this work, or is there a better way of doing it?

    Thanks
    -Rob
    http://www.sudsolutions.com

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Using VBA to disable Excel save function?

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
    Cancel as Boolean)
    a = MsgBox("Do you really want to save the workbook?", vbYesNo)
    If a = vbNo Then Cancel = True
    End Sub

    this should work, just set cancel = true

    pete

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Re: Using VBA to disable Excel save function?

    That seems to do the trick, thanks.

    Is is possible to do something similar with the Print function? I.e. disable it for that workbook. My app. has a report generation feature that I also want to be able to disable for the trial version.

    I've tried altering what you posted for the Save function so that it works for the Print function as well but not had any luck.

    Thanks
    -Rob
    http://www.sudsolutions.com

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Using VBA to disable Excel save function?

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    For Each wk in Worksheets
    wk.Calculate
    Next
    End Sub
    make cancel = true

    pete

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