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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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.
 

Grizlore

Active Member
Joined
Aug 22, 2006
Messages
259
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
 

Grizlore

Active Member
Joined
Aug 22, 2006
Messages
259
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,978
Messages
5,767,424
Members
425,411
Latest member
sarmientojayexce03

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
Top