Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to grab the OS User name and then automatically select a value in a listbox based upon this result. Have had a look at triggers and possible macro solutions but have had no joy. The username retrieved from the OSUser system variable is correct but not can seem to use this as selection crteria for a listbox, any help would be greatly appreciated.
Thanks
I am attaching a quick sample that automatically picks out the first letter of your OS Username in a field.
Here's the macro:
Sub Picker
userName = ActiveDocument.Evaluate("OsUser()")
firstLetter = Left(userName, 1)
ActiveDocument.Fields("Letter").Select firstLetter, true
End Sub
I have it set to run OnOpen.
hi
can you elaborate on your requirement??
what i understand is you want to select a value in the list box basis the osuser()
regards
Peter
Hi,
Thanks for the responses, have got this working in a macro now, but the triggers on open don't seem to run the macro. Can only get the macro to fire on clicking a button, not sure if this is a bug?
Thanks
Damien
Hi,
Will you please give me your macro code?
Thanks,
Mahasweta
The macro code I am using is:
sub UserName
set Uname = ActiveDocument.GetVariable("vUserName")
ActiveDocument.Fields("machine").Select Uname.GetContent.String
End Sub
The variable vUserName formula is =Upper(Right(osuser(),(len(osuser())-findoneof(osuser(),'\'))))
Set oShell = CreateObject( "WScript.Shell" )
utente=oShell.ExpandEnvironmentStrings("%UserName%")
if ucase(utente)="Guest" then
x
x
x
x