Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Protect my Excel file.

0

Hello Friends,

I have given a project excel file to my friend for his use. But I dont's want that he should forward the excel file to others. I want to protect that file to spread in his circle of friends.

If I use his computer motherboard or harddisk serial no. to protect/password the file. Or any other way to do that.

With Regards

pucha

Answer
Discuss

Answers

0

Please paste this to thisworkbook in you module

Private Sub Workbook_Open()
Dim MachineName As String
Dim UserName As String
' Get Host Name / Get Computer Name
MachineName = Environ$("computername")
' Get Current User Name
UserName = Environ$("username")
If MachineName = "LIN********4" Then
'do nothing
Else
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End If
End Sub
Discuss


Answer the Question

You must create an account to use the forum. Create an Account or Login