Password protect a file.

Dedes

New Member
Joined
Jan 15, 2010
Messages
24
Hi,

I am doing a project for my work and I don't want anybody to see how I am creating it.

My file has one sheet that is protected and also the VBA code is protected.
The sheet that is protected has a VBA module with the code below in order to let a macro change some values on that sheet.
Sheet5.UnProtect Password:="xxxxxx"
Sheet5.Protect Password:="xxxxxxxxxx"

However today I was surprised when a friend told me he could crack my file in 5 minutes.
I am very desapointed.

Is there any further way of proteting the file and making it impossible to crack?

many thanks
Dedes
 
Last edited by a moderator:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I am afraid that if an admin see your post will remove it
 
Upvote 0
I am afraid that if an admin see your post will remove it

I have written a legit post with a legit question.

I don't feel your post as being very friendly and because of that I have reported it to the moderators.

Regards
Dedes
 
Upvote 0
Dedes,

GK039 is not intended to be mean or anything like that. He is referring to rules #11 here: http://www.mrexcel.com/forum/showthread.php?t=99490.

It is the policy of the board to not have any posts that have any information that tell people how they can break passwords. While your question was not asking how to break a password (but rather how to protect it better), you did mention a program that can be used to break passwords. I simply removed the mention of that program, and the post is compliant now.

In regards to your question, unfortunately the security on programs like Excel are somewhat limited. If you are looking for some way to guarantee that someone can't break your VBA password, I am afraid that probably isn't possible. I don't think there is a way to make password protected code in Excel completely hacker-safe. At least not any that I have seen.
 
Upvote 0
Dedes,

GK039 is not intended to be mean or anything like that. He is referring to rules #11 here: http://www.mrexcel.com/forum/showthread.php?t=99490.

It is the policy of the board to not have any posts that have any information that tell people how they can break passwords. While your question was not asking how to break a password (but rather how to protect it better), you did mention a program that can be used to break passwords. I simply removed the mention of that program, and the post is compliant now.

In regards to your question, unfortunately the security on programs like Excel are somewhat limited. If you are looking for some way to guarantee that someone can't break your VBA password, I am afraid that probably isn't possible. I don't think there is a way to make password protected code in Excel completely hacker-safe. At least not any that I have seen.

Thanks Joe4 for you answer and sorry for posting the name of the program used to open my file.

I have had a long search on the web seeking a way of protecting my file and although I didn't find it I had an idea but so far is not enough to make my file safer.


Let me try to explain and maybe you can help me:

On my file I have a worksheet that is protected. And i also have soma VBA code protected.

So, I have made a little macro that when there is any activity on that worksheet a mesage box will pop up asking a question. If the right answer is not given the file gets protected again.

This is done and is working. The problem with it, is that if the person breaking my file also opens the VBA code can check the answer to my question. So I need something to help me protect the VBA. Do you have any idea?

I have thougth about somethiing producing a random number that will force the user to close the file and try again. But it being a random number he would never get it right. But I still haven't figure how to make this idea make sense.

thanks
dedes
 
Upvote 0
Have you tried:
VBE Tools Menu > VBA Project Properties > Protection tab > "Lock project from viewing" ?

Then see this:

http://www.mrexcel.com/forum/showthread.php?t=67918

And also this:

http://www.dombajsoft.com/protectvba.htm

Thanks Burrgogi

I think I will try my luck with some code I made to protect the worksheet and the Dombja Soft you sugested for the VBA. For now seems pretty secure.

But, this theme - security on EXCEL files - seems to me a very interesting one where we all could contribute with some ideas on how to create some possible code.

Dedes
 
Upvote 0
I haven't tried this myself, but a friend said he added a layer by hiding workbooks and the ribbons and only putting a command button on the first worksheet. Once clicked the user is prompted for another password.

As I said I have not tried this, but in theory it could work.
 
Upvote 0
I tried adding the additional security like my friend suggested and it is pretty easy.

You will need to create a commandbutton and a userform. Here is an example of the code needed.

Code:
'Located in the ThisWorkbook code
Private Sub workbook_open()
Application.ExecuteExcel4Macro "Show.Toolbar(""Ribbon"", False)"
Worksheets("sheet2").Visible = False
Worksheets("sheet3").Visible = False
End Sub

'Found in Sheet1 code
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

'Found behind the commandbutton1 on userform1.
Private Sub CommandButton1_Click()
If TextBox1.Value = "password" Then
Application.ExecuteExcel4Macro "Show.Toolbar(""Ribbon"", True)"
Worksheets("sheet2").Visible = True
Worksheets("sheet3").Visible = False
Else
MsgBox ("Sorry that is an invalid password" & vbCrLf & "Please Try Again")
TextBox1.SetFocus
End If
End Sub
 
Last edited by a moderator:
Upvote 0
I tried adding the additional security like my friend suggested and it is pretty easy.

You will need to create a commandbutton and a userform. Here is an example of the code needed.

Code:
'Located in the ThisWorkbook code
Private Sub workbook_open()
Application.ExecuteExcel4Macro "Show.Toolbar(""Ribbon"", False)"
Worksheets("sheet2").Visible = False
Worksheets("sheet3").Visible = False
End Sub

'Found in Sheet1 code
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

'Found behind the commandbutton1 on userform1.
Private Sub CommandButton1_Click()
If TextBox1.Value = "password" Then
Application.ExecuteExcel4Macro "Show.Toolbar(""Ribbon"", True)"
Worksheets("sheet2").Visible = True
Worksheets("sheet3").Visible = False
Else
MsgBox ("Sorry that is an invalid password" & vbCrLf & "Please Try Again")
TextBox1.SetFocus
End If
End Sub

[end code][/QUOTE]


Thanks Dartagna,

I will try it out.

Dedes
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,278
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top