Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Application.username
returns the name defined in Tools|Options|general Maybe using the windows logon id would be better: Option Explicit Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _ "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Function fOSUserName() As String ' Returns the network login name Dim lngLen As Long, lngX As Long Dim strUserName As String strUserName = String$(254, 0) lngLen = 255 lngX = apiGetUserName(strUserName, lngLen) If lngX < 0 Then fOSUserName = Left$(strUserName, lngLen - 1) Else fOSUserName = "" End If End Function sub testme() if lcase(fosusername) = "administrator" then 'do what you want else 'don't do it end if end sub Win XP wrote: From other post I realize that you disable the menu item by: Application.CommandBars("Tools").Controls("Protect ion").Enabled = False but, I want to disable it for everyone unless you log on as Administrator. I have tried the following, but it does not work. Private Sub Workbook_Open() If Application.UserName < "Administrator" Then Application.CommandBars("Tools").Controls("Protect ion").Enabled = False End If End Sub I cannot find the solution from other posts -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
is there anyway to make it so the users of my excel spread sheet cant view the macro code w/o a password? | Excel Worksheet Functions | |||
Does excel recognise names rather than cells? | Excel Worksheet Functions | |||
Copying multiple sheets from one book 2 another and undertake spec | Excel Discussion (Misc queries) | |||
Protecting Workbook | Excel Discussion (Misc queries) | |||
Naming & renaming a sheet tab | Excel Worksheet Functions |