Gif Help

wadiok

New Member
Joined
Jun 13, 2010
Messages
20
1.Sorry for the trouble but I want to check for user rights and I place a gif

called Picture1Click_() I have assigned Macros alright and design its function as WinUsername() I don't know how to tackle this?

Sub Picture1Click_()
'Grap username into first sheet

Range("a1").Value = WinUsername()
End Sub

Private Declare Function WNetGetUSer Lib "mpr.dll" Alias "WNetGetUserA"_
(ByVal IpName As String, ByVal IpUserName As String. IpnLength As Long) As Long

Private Const NO_ERROR = 0
Private Const ERROR_NOT_CONNECTED = 2250&
Private Const ERROR_MORE_DATA = 234
Private Const ERROR_NO_NETWORK = 1222&
Private Const ERROR_EXTENDED_ERROR = 1208&
Private Const ERROR_NO_NET_BAD_PATH = 1203&

Function WinUsername() As String
Dim strBuf As String, IngUser As Long, strUn As String
strBuf = Space$(255)
IngUser = WNetGetUSer("", strBuf, 255)
If IngUser = NO_ERROR Then
strUn = Left(strBuf, InStr(strBuf, vbNullChar) - 1)
WinUsename = strUn
Else
WinUsername = "error:" & IngUser
End If
End Function

Sub CheckUserRights()
Dim UserName As String
UserName = WinUsername
Select Case UserName
Case "Adminstrator"
MsgBox "Full Rights"
Case "Guest"
MsgBox "You Cannot Make Changes"
Case Else
MsgBox "Limited Rights:"
End Select
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,216,176
Messages
6,129,314
Members
449,501
Latest member
Amriddin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top