Wednesday 21 March 2018

How to block users opening an Excel file in VBA | Secure Excel file with VBA


If you want to secure your file to make sure that only you can open it, then you can add the below code in Workbook_Open function in your Excel file.

Note : Make sure you enter some thoughtful condition to make sure that only you open the file referring the code below.


Private Sub Workbook_Open()
    If Environ("username") <> "mm" Then ThisWorkbook.Close False
End Sub

No comments:

Post a Comment