Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Setting a variable in macro - Object Required error

Hi,

I'm trying to set a variable in a macro to the OS User name, so i can call the variable later in the macro and use it to write to a databse... However I'm getting an Object required error... heres my code

set table = ActiveDocument.GetSheetObject("TBComments")
set vUser = ActiveDocument.Variables("vOSUser").GetContent.String
For RowIter = 1 to table.GetRowCount-1
set vKPI = table.GetCell(RowIter,1)
set vMonth = table.GetCell(RowIter,2)
set vMeeting = table.GetCell(RowIter,0)
set vComment = table.GetCell(RowIter,4)
set vKey = table.GetCell(RowIter,3)

All of the variable are set ok, apart from the vUser one, the error i get is Object required: '[string: "ABC"]'

where ABC is the OS username and vOSUser is a variable in the document set to = OSUser()

I've also tried


set vUser = ActiveDocument.Evaluate("OsUser()")

Can anyone advise where I'm going wrong?

Thanks

Matt

Labels (1)
2 Replies
martinpohl
Partner - Master
Partner - Master

try this:

set vUser=ActiveDocument.getvariable("vOSUser")

Greetings

Martin

llauses243
Creator III
Creator III

Hi QQ,

to use this ... vUser = ActiveDocument.Variables("vOSUser").GetContent.String ( set exceed)

good luck, Luis.