Page 1 of 1 1
Topic Options
#48133 - 1999-09-10 05:21 AM How to write Office username and Initials with Kixtart
Anonymous
Unregistered


$counter=1
$Initials=""
$x = len (@userid)

while $counter =< $x
$Y=substr (ucase(@userid),$counter,1)
$ascii=asc ($y)
$hex=dectohex ($ascii)
$counter=$counter+1
;the spaces are to force at stringcopy.
$Initials=" "+$Initials+$hex+"00"
loop
$Initials=ltrim ($Initials) +"00" +"00"


$counter=1
$Name=""

$x = len (@fullname)

while $counter =< $x
$Y=substr (@fullname,$counter,1)
$ascii=asc ($y)
$hex=dectohex ($ascii)
$counter=$counter+1
$Name=" "+$Name+$hex+"00"
loop
$Name=ltrim ($Name) +"00" +"00"

;Check the keys for the right version of office

Writevalue("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Common\UserInfo","UserInitials",$Initials,"reg_binary")
Writevalue("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Common\UserInfo","UserName",$Name,"reg_binary")

Top
#48134 - 2001-02-08 12:11 AM Re: How to write Office username and Initials with Kixtart
Anonymous
Unregistered


Great script - thanks!
Top
#48135 - 2001-02-08 12:24 AM Re: How to write Office username and Initials with Kixtart
Anonymous
Unregistered


Can anyone find where the Mailing address for word is stored? I'd like to set that too, but I can't find it in Office 2000.

It's called UserAddress in Office97, but it's not there in Office 2000

Top
#48136 - 2002-07-08 11:49 PM Re: How to write Office username and Initials with Kixtart
xpanmanx Offline
Starting to like KiXtart

Registered: 2002-07-08
Posts: 108
Loc: St. Louis MO USA
code:
Updating this thread with my code for Office XP.

Our AD uses last-name-first fullnames, so there's code in here to "turn around" the user's name.

---------------------------------------------

$comma = instr(@fullname,",")
$firstname = ltrim(substr(@fullname,$comma+1,len(@fullname)-$comma))
$middleinitial=("")

if instr(@fullname,".")
$middleinitial=ltrim(substr($firstname,len($firstname)-2,2))
endif

$lastname = ltrim(substr(@fullname,1,$comma-1))
$firstnamefirst=$firstname + (" ") + $lastname
$firstinitial = ltrim(substr($firstname, 1, 1))
$lastinitial = ltrim(substr($lastname, 1, 1))
$initials=$firstinitial + $middleinitial + $lastinitial

$x=1
$usernamehex=''
while $X<len(''+$firstnamefirst)+1
$usernamehex=$usernamehex+dectohex(asc(substr($firstnamefirst,$x,1)))+'00'
$x = $x + 1
loop
$usernamehex=$usernamehex + '0000'

$x=1
$userinitialshex=''
while $X<len(''+$initials)+1
$userinitalshex=$userinitialshex+dectohex(asc(substr($initials,$x,1)))+'00'
$x = $x + 1
loop
$userinitialshex=$userinitialshex + '0000'

WriteValue ("HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Common\UserInfo", "UserName", $usernamehex, "reg_binary")
WriteValue ("HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Common\UserInfo", "UserInitials", $userinitialshex, "reg_binary")


Top
#48137 - 2002-07-09 06:39 AM Re: How to write Office username and Initials with Kixtart
xpanmanx Offline
Starting to like KiXtart

Registered: 2002-07-08
Posts: 108
Loc: St. Louis MO USA
Then I came up with this code, a doctoring of some from the FAQ section of this BB.

From a first-name-first @fullname, this code splits out first and last names, removes the MI-followed-by-period from the first name (if present) and gets you two or three initials as the result.

code:
$splitbetweennames = instr(@fullname," ")

if instr(@fullname,". ")
$splitbetweennames = instr(@fullname,". ")
endif

$firstname = substr(@fullname,1,$splitbetweennames)

$firstnametemp = $firstname

if instr(@fullname,". ")
$firstnametemp = substr(@fullname,1,len($firstnametemp)-3)
endif

? "First name, no MI: " $firstnametemp

$lastname = ltrim(substr(@fullname,$splitbetweennames+1,len(@fullname)-$splitbetweennames))

? "Last name: " + $lastname

$firstinitial = ltrim(substr(@fullname,1,1))

$middleinitial=("")

if instr(@fullname,".")
$middleinitial=ltrim(substr($firstname,len($firstname)-2,2))
endif

$lastinitial = ltrim(substr($lastname,1,1))

? "initials: " + $firstinitial + $middleinitial + $lastinitial


Top
#48138 - 2002-07-09 08:58 AM Re: How to write Office username and Initials with Kixtart
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
Hasn't this code been posted before?

[Smile]
_________________________
Who are you? Who slips into my robot body and whispers to my ghost?

Top
#48139 - 2002-07-09 09:01 AM Re: How to write Office username and Initials with Kixtart
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
In the FAQ Section, there is a topic that covers this, specifically: Initials of a User - String Manipulation

Regards,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.058 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org