A
AccessHelp
Good morning,
I have a command button in a workbook to run a macro. However, when a user
clicks on the button, the macro will check first automatically whether the
user who clicks on it has an authority to run the macro. If not, the user
will receive a message "Access denied.".
So I came up with the following code:
If Application.UserName <> "John Doe" Then
Msgbox "Access denied."
Else
run the remainder of code......
End If
2 questions:
1. What does the UserName Property check against with? Does it check
against with Windows user name or computer user name? When I did the code
"Msgbox Application.UserName", I got my first and last names.
2. I will have more than one authorized users, and instead of having the
code "If Application.UserName <> "John Doe" Or If Application.UserName <>
"John Smith" Or ......", can you help me with better coding?
Thanks.
I have a command button in a workbook to run a macro. However, when a user
clicks on the button, the macro will check first automatically whether the
user who clicks on it has an authority to run the macro. If not, the user
will receive a message "Access denied.".
So I came up with the following code:
If Application.UserName <> "John Doe" Then
Msgbox "Access denied."
Else
run the remainder of code......
End If
2 questions:
1. What does the UserName Property check against with? Does it check
against with Windows user name or computer user name? When I did the code
"Msgbox Application.UserName", I got my first and last names.
2. I will have more than one authorized users, and instead of having the
code "If Application.UserName <> "John Doe" Or If Application.UserName <>
"John Smith" Or ......", can you help me with better coding?
Thanks.