• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Protect a button

Shazz

Member
Hi All,

Is it possible at all to either password protect a button that has a hyperlink to another spreadsheet attached to it, or is it possible for it to only work if I click on it (As a user).

Basically the button is just a shape with a hyperlink attached.

Your help would be appreciated.
 
Do the changes in below code.

Code:
Sub call_me()
Dim myuser As String

myuser = Application.UserName

If myuser <> "dEEPAK" Then Exit Sub
'now your code here
MsgBox "Do what you want", vbInformation

End Sub
 
Where do I put this, is it a macro to be attached to the button, if so can a hyperlink and macro be attached to one button.

Sorry I am still learning all this.
 
Can you tell me if I have altered the code correctly.

Code:
Sub call_me()
Dim myuser As String

myuser = Application.UserName

If myuser <> "Sharon.Slatter" Then Exit Sub
'now your code here
MsgBox "Sorry, you do not have access to this Database", vbInformation

End Sub
 
Can you tell me if I have altered the code correctly.

Code:
Sub call_me()
Dim myuser As String

myuser = Application.UserName

If myuser <> "Sharon.Slatter" Then Exit Sub
'now your code here
MsgBox "Sorry, you do not have access to this Database", vbInformation

End Sub


No,It's wrong. Pls share your hyperlink so that same can be integrated or check this.

Code:
Sub call_me()
Dim myuser As String

myuser = Application.UserName

If myuser <> "Sharon.Slatter" Then
    MsgBox "Sorry, you do not have access to this Database", vbInformation
Exit Sub
End If

'now your hyperlink code here

End Sub
 
Hi the Hyperlink Code is below. I would also need to know exactly where this code goes, as I have no idea.

\\bbufile001\Crossways Data\Tcddata\Slatter\BBUSL Employee Database.xls
 
Place it in a module.


Screenshot 2015-02-18 19.31.39.png


Code:
Sub call_me()
Dim myuser As String

myuser = Application.UserName

If myuser <> "Sharon.Slatter" Then
    MsgBox "Sorry, you do not have access to this Database", vbInformation
Exit Sub
End If

ActiveWorkbook.FollowHyperlink "\\bbufile001\Crossways Data\Tcddata\Slatter\BBUSL Employee Database.xls", , True

End Sub
 
Thank you, only one problem - I have put my email address into the code (as i didnt want to show it in the code on here) and it is coming up with Sorry, you do not have access to this database.

I sign into the computer with my email address so assume this should have worked. Have you got any ideas??
 
Code:
If LCase(myuser) <> LCase("abc@xyz.com") Then
    MsgBox "Sorry, you do not have access to this Database", vbInformation
Exit Sub
End If
 
I am really sorry and I know I am a pain but it is still not working. I am still getting "Sorry, you do not have access to this Database"

The code I now have is

Code:
Sub call_me()
Dim myuser As String

myuser = Application.UserName

If LCase(myuser) <> LCase("sharon.slatter@????.com") Then
    MsgBox "Sorry, you do not have access to this Database", vbInformation
Exit Sub
End If
' \\bbufile001\Crossways Data\Tcddata\Slatter\BBUSL Employee Database.xls

End Sub
 
Do a thing!!
Just place the below code in a module & run. You will see your username in a1 of active sheet.
Copy that to the above code & check.

Code:
Sub my_u()
[A1] = Application.UserName
End Sub
 
I have done that and it gives me exactly what I have put in the code, so I have no idea now what to do.

Maybe I will just leave it.

Thanks for your help though.
 
I have tried both my User name (Sharon.Slatter) and my email address (sharon.slatter@?????.com) never of them worked.
 
Sorry Deepak I am very new to this ans need it spelt out to me, do you mean put the above in a module and run it??
 
Check this.

Code:
Sub AccessMyFoler()
Dim myuser As String, myU As String

myuser = LCase(Application.UserName)
myU = LCase("Sharon.Slatter")

If myuser <> myU Then
    MsgBox "Sorry, you do not have access to this Database", vbCritical
Exit Sub
End If

ActiveWorkbook.FollowHyperlink "\\bbufile001\Crossways Data\Tcddata\Slatter\BBUSL Employee Database.xls", , True

End Sub
 
Back
Top