Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

OS User

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

6 Replies
Not applicable
Author

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.

Not applicable
Author

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

Not applicable
Author

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

Not applicable
Author

Hi,

Will you please give me your macro code?

Thanks,

Mahasweta

Not applicable
Author

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(),'\'))))

Not applicable
Author

Set oShell = CreateObject( "WScript.Shell" )
utente=oShell.ExpandEnvironmentStrings("%UserName%")
if ucase(utente)="Guest" then

x

x

x

x