Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using Windows Environment Variable from Macro?

I want to be able to use a Windows Environment variable (i.e. TEMP) from Macro. Want to specify where my exported file is located. Is this possible?

ActiveDocument.GetSheetObject( "Check01Chart01" ).Export "$(TEMP)\test01a.csv", ","

7 Replies
Not applicable
Author

I believe there is a method called ExpandEnvironmentStrings. Sorry don't have any example code, but I'm sure it's easy to google-

Not applicable
Author

Thanks, but googling on QlikView & ExpandEnvironmentStrings does not return any information on such a function.

llauses243
Creator III
Creator III

Hi ,

Moreover atach .vbs

Then is possible to pass %TEMP% to variable.

Goos luck, Luis

Not applicable
Author

Hi,

You can do same with less lines from script



EXECUTE cmd /C "set > var.txt" ;
LOAD
@1 as var_name,
@2 as var_value
FROM [var.txt] (txt, codepage is 1252, no labels, delimiter is '=', no quotes);




-Alex

Not applicable
Author

Add the code to the script but now getting the warning dialog below and I can't figure out where to "permanently check the Execute option for the script". Where do I set the execute option? Thanks.

Not applicable
Author

Open script, there is setting "can execute external programs"

-alex

Not applicable
Author

Another script-based method which doesn't use temporary files is to query the environment variables directly from the registry:


LET env_var_value = GetRegistryString('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'env_var_name');


Simon