Consulting

Results 1 to 3 of 3

Thread: Vba, How can code the excel file to save as only and disable to save directly file

  1. #1

    Vba, How can code the excel file to save as only and disable to save directly file

    Hi Friends,

    Please help to share vba macro code.

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,199
    Location
    Hi Mawar,

    This may not be the best solution but it will give you a start.
    Keep in mind that if the user chooses not to enable macros then they will be able to save the workbook.

    The solution below will prevent the save and instead offer the save as dialogue.

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
        If Not SaveAsUI Then
            Cancel = True
            MsgBox "You cannot save this workbook, save as only"
            Application.Dialogs(xlDialogSaveAs).Show
        End If
        
    End Sub
    This code will need to go into the "ThisWorkbook" code window.

    Hope this helps
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  3. #3
    Alternatively you could set a password to modify the file. If password is not entered, the file is read-only. No VBA required.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

Tags for this Thread

Posting Permissions

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