-1

I have a xlsm workbook and with 2 sheets, I call it as workbook 1, sheet 1 is visible, sheet 2 is set as xlsheetveryhidden. And then vbe password setted.

Now the situation should be no one can unhide sheet 2 manaually, right?

Now I open another workbook, I call it as workbook 2, open vbe at workbook 2, and simply type the following codes and aim to workbook 1, sheet 2 is visble:

Sub InvisibleSheet2Fails()
Sheets(2).Visible = xlSheetVisible
End Sub
 

My question is: How can I unhide my sheet 2 ONLY with workbook 1 vbe password? workbook 2 doesn't know the workbook 1 vbe password but can easily bypass xlsheetveryhidden setting.

Thank you very much!

Lawrence

Yung Lin Ma
  • 121
  • 2
  • 14
  • Perhaps you could learn a real programming language? VBA Security... pffft! – suchislife Mar 20 '18 at 02:22
  • Yes, you are right. But I am using excel to quick develop a dashboard-like project. Installing python at company is completely difficult.. (submititng form, IT assessment.. and so on..) – Yung Lin Ma Mar 20 '18 at 02:29
  • @ASPiRE, I am interested, how to create certificates locally and allow assigned people to access them? – Yung Lin Ma Mar 20 '18 at 02:36

2 Answers2

2

No security is 100% safe. If your threat model is a power user that knows how to bring up the VBE and you don't want them fiddling around, you can at least protect the workbook structure with a password.

ThisWorkbook.Protect "password", Structure:=true

Do this from the immediate pane, don't put the password anywhere in the code - VBE password protection on the other hand (you seem to be conflating VBA project protection and workbook structure protection), is absolutely easily defeated, in no time; if you've written the password anywhere in the code, consider it compromised.

Use a good, strong password, and if you're using the latest version of Excel and someone manages to unprotect the workbook, they deserve to tweak it.

If your threat model is a MI6 agent, if they get to the file in the first place, you already lost: put the file somewhere safe, implement good network security.

Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
  • @ Mathieu Guindon, this works perfectly! Thank you very much! however, one more small question: "ThisWorkbook.Protect "password", Structure:=true" how to code above "password" via vba to enter and change the sheet? – Yung Lin Ma Mar 20 '18 at 03:42
  • @ Mathieu Guindon, I tried it works on Thisworkbook "ThisWorkbook.Protect "password" How can I use the above "password" to change the sheets? – Yung Lin Ma Mar 20 '18 at 03:48
  • @ Mathieu Guindon, Could you please tell me more about how to set the password not in VBE? Thank you very much , very interested! – Yung Lin Ma Mar 20 '18 at 04:00
  • In Excel, from the [Review] tab, find the [Protect Workbook] button. – Mathieu Guindon Mar 20 '18 at 04:05
  • In your code you can use a variable to stand for the password protecting the structure and then use Inputbox to get the user to enter the actual password Dim pword as string:pword = inputbox("enter password") – Harassed Dad Mar 20 '18 at 10:30
0

Honestly and sincerely, I have not found an office file that could not be hacked.

Besides the tools available for purchase used to do just that, you can also find them for free as well.

If you're really serious about protecting these files, you could trying Encrypting them and allowing only those who have the certificates locally, access them.

See Information Rights Management in Office

"If you've gotten a file permission error when trying to view a document or email, then you have come across Information Rights Management (IRM). You can use IRM to restrict permission to content in documents, workbooks, and presentations with Office."

suchislife
  • 4,251
  • 10
  • 47
  • 78
  • seems should not that complicated.. I just want people who have vbe password to change my workbook; No vbe password, no change of my workbook.. – Yung Lin Ma Mar 20 '18 at 02:42
  • 2
    @YungLinMa the VBE password protects access to the VBE; it doesn't protect the structure of the workbook (e.g. position, name and visibility of the sheets). Use workbook protection for that. – Mathieu Guindon Mar 20 '18 at 03:27