Changing the User Initials of Office 2003 Applications using VB Script

I had posted a question previously in order to change the Username Popup Box when Office 2003 Applications are opened.

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Remote_Desktop-Terminal_Services/Q_25335235.html

Now I have a similar requirement, but this time I need a VB Script that can change the User Initials in addition to Username field of the popup box which opens up when a new user opens Word, Excel or Powerpoint.
LVL 19
vmwarun - ArunAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yehudahaCommented:
change it to what ?
0
vmwarun - ArunAuthor Commented:
This was the previous VB Script which was given by one of the Experts.
 
0
vmwarun - ArunAuthor Commented:

Set oFSO = CreateObject("Scripting.FileSystemObject") 
Set oShell = CreateObject("Wscript.Shell") 
 
' get UserName 
strUsername = oShell.ExpandEnvironmentStrings("%USERNAME%") 
 
'msgbox strusername 
 
' Convert UserName to hex 
For i = 1 to Len(strUsername) 
  strUsernameHex = strUsernameHex & "," & Hex(Asc(Mid(strUsername, i, 1))) & ",00" 
Next 
strUsernameHex = Right(strUsernameHex, Len(strUsernameHex) -1) 
strUsernameHex = strUsernameHex & ",00,00" 
 
' Create temporary registry file 
Const OverwriteIfExist = -1 
Const FailIfExist      = 0 
Const OpenAsASCII   =  0 
Const OpenAsUnicode = -1 
Const OpenAsDefault    = -2 
sTmpFile = oShell.ExpandEnvironmentStrings("%TEMP%") & "\UserInfo.reg" 
Set fFile = oFSO.CreateTextFile(sTmpFile, OverwriteIfExist, OpenAsASCII) 
 
' Write to the temporary registry file 
fFile.WriteLine "REGEDIT4" 
fFile.WriteLine 
fFile.WriteLine "[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo]" 
fFile.WriteLine """UserName""=hex:" & strUsernameHex 
fFile.Close 
 
' Import the registry file 
oShell.Run "regedit /s " & sTmpFile, 0, True 
 
' Delete the temporary registry file 
oFSO.DeleteFile sTmpFile

Open in new window

0
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

yehudahaCommented:
you want to change the initial to the user log on ?
0
yehudahaCommented:
user name or display name ?

johnd or jhon doe
0
vmwarun - ArunAuthor Commented:
Yes, intial to the user logon on. For initials I would prefer to leave them empty, so if user requires, they can update it for the first time.
0
yehudahaCommented:
save as vbs

you will ask the user if he want to update his initial, will update user name
if you want some thing else to update let me know
Set objnet = CreateObject("WScript.Network")
Set objWord = CreateObject("Word.Application")
strInput = msgbox("Update Your Initial For Office Application ?",4)
Select Case strInput
Case 6
objWord.UserInitials = objnet.username
objWord.Quit
Case 7
objWord.Quit
End Select

Open in new window

0
vmwarun - ArunAuthor Commented:
Let me check and update.
0
yehudahaCommented:
Works ?
0
vmwarun - ArunAuthor Commented:
I was unable to check because I was held up with other issues. I will check and update tomorrow.
0
vmwarun - ArunAuthor Commented:
We already added the code to Production attached by me, so is it possible to add or modify the code and update it accordingly,
0
yehudahaCommented:
i think this will do

at the end of your script add this code:
call ini

sub ini
      Set objnet = CreateObject("WScript.Network")
Set objWord = CreateObject("Word.Application")
strInput = msgbox("Update Your Initial For Office Application ?",4)
Select Case strInput
Case 6
objWord.UserInitials = objnet.username
objWord.Quit
Case 7
objWord.Quit
End Select
end sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vmwarun - ArunAuthor Commented:
Let me check this by adding these additional lines of code and reply back.
0
vmwarun - ArunAuthor Commented:
I was not able to put this in Production but I would like to award points for the assistance.
0
yehudahaCommented:
many thanks
0
ariadminCommented:
Anyway to edit the script to only use the first 9 characters of a 'username' since the initials variable is limited to 9 characters? While i love this script, users with long last names are getting errors (string too long).

thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Server OS

From novice to tech pro — start learning today.