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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

VB Macro Query

Hi Team,

ActiveDocument.Variables("Var1") .GetContent.String

The above code is working if i write this in

Sub test()

End Sub

But If i write it inside function like below

Function Test()

End Function

it is not working...At the time of reload, QV application getting closed automatically everytime.

Any suggestion please!!

8 Replies
Not applicable
Author

Hi Arun

This might not be exactly what you want to hear, but here goes anyway:

Why not put it in a Sub? What is the problem with a Sub?

Not applicable
Author

Hi Arun,

Test my attached example, it works fine for me.

Best regards.

Not applicable
Author

Hi Miguel,

Thanks for the reply.

I have to use the output of subroutine in to load script. Since Sub can't return a value i've to use Function only.

I am attaching the same qv you sent to me with two changes:

a. Changed TestFunction in Macro editor. Now it is returning the value of the variable.

b. Calling TestFunction from Load Script.

Try to load the data. Its not working.

Please suggest!!

Not applicable
Author

Hi Around,

I don't understand if what you need is changing the variable value in the macro function before the load script execution or simply you need get back the last value of the variable. I've attached a possible solution to the second point. The solution for the first point will depends what you need.

Check out my attached example and let me know if it is what are you looking for.

Best regards.

Not applicable
Author

Hi Miguel,

Thanks for your efforts.

It doesn't matter what we want from the variable - we might be using it in some calculation etc. What I want is to call a macro function from Load Script - Its simple and I am doing this for a long time.

My problem is that when i am calling a function from a load script, its not working if i am capturing some variable into that function.

Not applicable
Author

Hi Arun,

I think this problem doesn't have any solution, I found this possible explanation for your case:

"If your macro is trying to navigate through the ActiveDocument, as of 8.2/8.5 most of the ActiveDocument properties do not exist during script execution."

Sorry about that.

Best regards.

Not applicable
Author

Hi Arun.

Did you get any solution how you can call a Macro from Load script?

I'm looking for same solution...

regards,

Daniel

Not applicable
Author

I fix it - via settings -> document properties -> triggers