Page 1 of 1 1
Topic Options
#165953 - 2006-08-15 04:35 PM Word User Informatiom
DJM Offline
Fresh Scripter

Registered: 2006-08-15
Posts: 10
Hi guys,

I'm very new to Kix, and have been asked to write a script that amends the user information in word using the @fullname function. Now, I have a script (which I'll attach at the end of this posting), that works, but the company I work for have 3 parts to the full name (firstname, lastname and company name). The script reads the company name as the last name, but I obviously need the actual last name. Can anyone help me ?


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;'start of script [OfficeInfo_Reg.Kix]';
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$A = len(@fullname)

$B = 1

while $B < $A+1

$result = DecToHex (Asc(Substr(UCase(@fullname),$B,1)))

if $result = "20"
$incount = ($B*4)+1
endif

$hexstring = $hexstring + $result + "00"

$B = $B + 1

$C = $hexstring+"0000"

$Myarray = Split("@fullname"," ")
For Each $Element In $MyArray
? $Element
Next

$initials = Substr($C,1,4)+Substr($C,$incount,8)+"0000"

$RC=WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo", "UserName", $C, "REG_BINARY")
$RC=WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo", "UserInitials", $initials, "REG_BINARY")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;'End of script [OfficeInfo_Reg.kix]';
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Top
#165954 - 2006-08-15 09:02 PM Re: Word User Informatiom
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Welcome to the board.

First off....

What version of KiXtart are you using?
Have you looked in the UDF forum - there are a couple of UDFS that might do this already for you.

Okay, what is the exact pattern of the name and is it consistent?

FIRST, LAST, COMPANY or FIRST LAST COMPANY or FIRST - LAST - COMPANY or some other combination.

ie.. are there any types of delimiters used in what is returned by the @FULLNAME macro ?




GetOfficeDetails2() - Get MS Office version details
http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=107933

MSOfficeUser() - set office user information
http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=83554


Edited by NTDOC (2006-08-15 10:51 PM)

Top
#165955 - 2006-08-16 09:48 AM Re: Word User Informatiom
DJM Offline
Fresh Scripter

Registered: 2006-08-15
Posts: 10
I'm using Kix 2010 (version 4.52)

The exact pattern returned by the fullname marco is :

Firstname Lastname (Company name)

The brackets for the company name are returned by the marco

Top
#165956 - 2006-08-16 11:23 AM Re: Word User Informatiom
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Okay well this code should work for you then.

Code:
Dim $FN
$FN = Left(@FullName,(InstrRev(@FullName,'('))-1)
'Full name is: ' + $FN ?


Top
#165957 - 2006-08-16 11:35 AM Re: Word User Informatiom
DJM Offline
Fresh Scripter

Registered: 2006-08-15
Posts: 10
That works a dream. Thanks for your help.
Top
#165958 - 2006-08-16 11:39 AM Re: Word User Informatiom
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
No problem, glad to be of assistance.
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
1 registered (Allen) and 4358 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.11 seconds in which 0.072 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