Prompt to change user name

Grizlore

Active Member
Joined
Aug 22, 2006
Messages
259
Could anyone help please?

Some Users have their full name as the user name within Excel, some just have their three initials.

Is there a way of promting the User to change their stored user name if it is only 3 characters long.

Ideally, I would like an input box to help them change it.

If someone could give me a point in the right direction, it would be appreciated.


Thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
What have you tried? The Application object's UserName property contains the user name and is read/write. You can use the Len funtion to check its length. You can use the InputBox function to prompt the user for input.
 
Upvote 0
I have bodged this together (hope the code posts ok)

Any suggestions... it seems to do what I need, after your kind advise :)

Once the Application.username is changed... does it stay changed???

Code:
Option Explicit

Sub UserName_checker()

Dim Username As String
Dim NewName As String

If Len(Application.Username) = 3 Then _

NewName = InputBox("Your username is not your fullname..blarr...enter below", _
    "Please enter full name", "Enter your full name HERE")

If NewName = "Enter your full name HERE" Or _
NewName = "" Then
Exit Sub
End If

Application.Username = NewName

MsgBox "Thanks, your Username has now been changed within Excel"

End Sub

Andrew, once again... thanks for your help/advice
 
Upvote 0
My final code is...

I have intentionally changed my original idea of 3 digits long, to <5

Code:
Sub UserName_checker()

Dim Username As String
Dim NewName As String

On Error GoTo 0

Application.ScreenUpdating = False

If Len(Application.Username) < 5 Then NewName = InputBox("It appears that Excel isn't using your full name.", _
    "Your Username is currently stored as " & Application.Username, "Enter your full name HERE")

If NewName = "Enter your full name HERE" Or _
NewName = "" Then
Exit Sub
End If

Application.Username = NewName

ActiveWorkbook.Save

Application.ScreenUpdating = True

MsgBox "Your Username has now been changed to " & UCase(NewName) & " within Excel", , "Name change notification"


End Sub

any comments welcome
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,465
Members
448,965
Latest member
grijken

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