Link to home
Start Free TrialLog in
Avatar of gordontm
gordontm

asked on

Stopping people seeing code in Excel

I am using ExcelXP

I know how to password protect the code. What I don't know how to do, is to hide the code after "unlocking it", short of closing down the application and reopening it.

I know this might seem trivial to close down and reopen the application but it is a big Excel application running over a slow network!
Avatar of victoresq
victoresq

no need to worry mate,

each person who opens the XLS file will start a new "instance" of the file.

So while you are working on it in on your box in your instance, it is totally different from Suzzie Q trying to see the code.

I created an XLS spreadsheet on the network that contained a single comment in the click event of a button that said " 'I am hiding from the world "

I put a password and closed the file the first time.

When I re-opened it from my box, it of course wanted the password. so when I gave it, I was granted access.

From another box I opened the same file, it of asked me for the password to see the same code (even though I had opened it earlier and continued to keep it opened.

Let me know if this is not the behavior you experience.

whodaman
Avatar of gordontm

ASKER

Thank you for your comments...
I may not have explained myself well enough.

I want to go to a User's machine. She is using a program I wrote, and I want to make a quick change to the code. If I enter the password and make the change, I am forced to close down the program afterwards in order to stop further access to the code on that machine.
I can feel your pain, I was doing this for Enron (before the defunction) and would have to relay to that user that just like any development should be done on my box (for testing).

the design mode button is the seventh button in the visual basic toolbar...basically you are turning the enabling on and off for this item.  set the passwords to whatever you like...see ya.

whodaman

********************************************************

Private Sub CommandButton2_Click()
Call checkProtectionforVBProject
End Sub


Private Sub checkProtectionforVBProject()

    Dim userAnswer As String
   
    userAnswer = InputBox("password please")
   
    If userAnswer = "u" Then

        Application.Toolbars("Visual Basic").ToolbarButtons(7).Enabled = True

    ElseIf userAnswer = "p" Then

        Application.Toolbars("Visual Basic").ToolbarButtons(7).Enabled = False
   
    Else
   
        MsgBox "Your answer was not recongnized"
   
    End If

End Sub

did this help?
Victoresq
Hi. Thanks for your comment. I am really sorry for the 2 month delay in replying - I have been really snowed under at work and didn't have time for this development.
I am afraid that this isn't exactly what I was looking for.
I see that the code will enable or disable the Design button in the vb toolbar. However it doesn't stop me going into the code with ALT-F11
Even if Use your code to disable the 4th button (Visual Basic Editor) it is still possible to go in via the menus or via the keyboard (ALT-F11)
Thanks anyway





ASKER CERTIFIED SOLUTION
Avatar of victoresq
victoresq

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you! Have a good weekend