Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
ilanbaruch
Specialist
Specialist

Execute Macro from Load Script

hi all

in my model I have a Macro script

I want to execute this macro from within the load script, is that possible ?

advanced thanks

Labels (2)
8 Replies
cwolf
Creator III
Creator III

Macro functions can be used like QlikView functions in the load script. For example via a variable assignment:

let result=VBFunctionName();

ilanbaruch
Specialist
Specialist
Author

and than ? 

execute ?

cwolf
Creator III
Creator III

For example you have a function:

function Test1()
	' Type your VB script here
        .
        .
        .
 	'return a result
 	Test1="Ok"
end function

 

then the line

let result1=Test1();

will execute the function.

 

You can also use functions with parameters:

function Test2(param1,param2)
 	Test2=param1 & " " & param2 & "!"
end function

 

let result2=Test2('Hello','World');

The variable result2 now contains "Hello World!".

ilanbaruch
Specialist
Specialist
Author

first of all thank you.

I have the macro script as in your example. it is ready and working if I trigger it from UI.

the macro script is in the macro script section (Ctrl+M) I want to trigger it from the script editor  (Ctrl+E) .

i set the variable as you suggested but it isn't working

cwolf
Creator III
Creator III

See attachement.

rwunderlich
MVP & Luminary
MVP & Luminary

As @cwolf said, you can trigger Functions from the script, but not Subs. If your code is in a Sub, you will need to define a Function that calls the Sub. 

When called from the script,  VB Macro code cannot access the ActiveDocument object. So if you trying to do something like access chart data your macro will not work from script. 

-Rob

ilanbaruch
Specialist
Specialist
Author

Hi, thank you for you replay.

you are right , the function is within a sub.

how can call this sub from a function ?

rwunderlich
MVP & Luminary
MVP & Luminary

Sub MySub
  ....
End Sub

Function MyFunction
  Call MySub
End Function