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

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

VBSCRIPT calling document.Variable("MyDate")

Some of my documents have "MyDate" variable defined and some dont. I have a code snipped that i posted below that runs for both documents that have the variable and ones that dont. The isnull() is there to test to see if the newdoc.Variables("MyDate") statement actually returned a value. Still, I get an "object required: vbstart" error on this line, "vbstart.SetContent StartDate,true". I know the object does not exist in my document (for my test case) but how do I test for this so I only execute the SetContent if the variable exists? I tried isnull() and also "if vbstart is Nothing then"... Any ideas? Thanks!

ps, I apologize for how the copy and paste from QV script looks. I'll try and fix it up by putting it into notepad or someting...

set vbstart = newdoc.Variables("MyDate")

if not isnull(vbstart) then

vbstart.SetContent StartDate,true

end if













1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Use a typename() test instead:

set vbstart = newdoc.Variables("MyDate")
If typename(vbstart) = "Variable" then
vbstart.SetContent StartDate,true
end if

-Rob

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Use a typename() test instead:

set vbstart = newdoc.Variables("MyDate")
If typename(vbstart) = "Variable" then
vbstart.SetContent StartDate,true
end if

-Rob

Anonymous
Not applicable
Author

Works great. THanks Rob. I was using document.CreateVariable in the meantime but it was a bit of a Kluge.