Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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!".
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
Macro functions can be used like QlikView functions in the load script. For example via a variable assignment:
let result=VBFunctionName();
and than ?
execute ?
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!".
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
See attachement.
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
Hi, thank you for you replay.
you are right , the function is within a sub.
how can call this sub from a function ?
Sub MySub
....
End Sub
Function MyFunction
Call MySub
End Function
Thank you