Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UserProofing and .Quit 1

Status
Not open for further replies.

THarte

Programmer
May 8, 2002
28
US
I almost UserProofed myself. I launch a form when my workbook launches. I have 3 "Exit" Command Buttons on three different forms. When a User hits any "Exit" I want Application.Quit. I could not figure out how to get around the Application.Quit so I could view my code and sheets. Luckily I left an out on one of the sheets.

How Do I userproof with Application.Quit yet allow myself to get in and manipulate as necessary? Or is there a better way to have the user exit all the way out?
 
If you are on NT (eee then
myUserName = environ.username
if myUserName = "YourUserNAmeGoesHere" then
exit sub
else
application.quit
end if

If not NT, there's an API call you can use. Let me know and I'll post it if necessary
Geoff
 
I am on Win2K.

I figured out a not very secure way of doing it by Putting "End" rather than "Application.Quit" on a label. Made the label blend in so it could not be seen and placed it somewhere I only know where it is.

Not very sophisticated but it worked.

If you could tell me the name of the API I will find it.
 
This should do the trick:

Public UserName As String

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Sub Get_User_Name()

Dim lpBuff As String * 25
Dim ret As Long
ret = GetUserName(lpBuff, 25)
UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Sub

HTH
Geoff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top