
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Execute a Macro inside load script
Hi All,
is possible execute an Qlikview macro inside a load script?
Tks
- « Previous Replies
-
- 1
- 2
- Next Replies »
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure! Just create it and then use it in the macro - Qlikview will look for it at load time if it cannot find a native function. For example I created this function which I use in a script:
Function MonthDiff (startdate, enddate)
' return number of months between two dates
If IsDate(startdate) and IsDate(enddate) Then
MonthDiff = DateDiff("m", startdate, enddate)
End If
End Function
Regards,
Gordon

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure! Just create it and then use it in the macro - Qlikview will look for it at load time if it cannot find a native function. For example I created this function which I use in a script:
Function MonthDiff (startdate, enddate)
' return number of months between two dates
If IsDate(startdate) and IsDate(enddate) Then
MonthDiff = DateDiff("m", startdate, enddate)
End If
End Function
Regards,
Gordon

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tks Gordon for your reply.
I created a function and into load script I execute it by CALL command.
Call MonthDiff()
Regards.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I tried this very same code and get "Script line error" in Call MonthDiff()
what could it be, has the syntax changed?
thanks,
.png)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
If you are calling the function from the load string, do as follows instead
LET vExecFunction = MonthDiff();
If the function in the macro editor (CTRL + M) is built using Sub / End Sub instead of Function / End Function, then use CALL in the script.
Hope that helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you use the code as in my example then it is a function not a sub - you call a sub but not a function. So, to use my code you would simply have in the script:
MonthDiff(date1, date2)
Regards,
Gordon


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Gordon, I'm just trying the same as you. Loading a macro inside the loading script.
I have many problems doing that.
When I write in my loading script :
call myFunction()
I got an error message.
My suggestions is :
1- You can only call the macros in VBScript ( I have my macros in jscript).
2-I've tried both ways to get the same result (functions in javascript and vbscript), and I still can't get it work.
Any Ideas about what I'm doing wrong??
Many thanks in advance!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I dont undertstand what the problem is - I use the function (VBS) in several documents and they work just fine in v9sr4 and previously in v8.2.
Is your problem just the dates you are passing to the function being invalid or the wrong format?
Regards
Gordon


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, in fact I'm not using your dates function. Actually, I have a document with "jscript" macros. And I would like to execute a macro (that generates xml files) before reloading the document with the new day information.
I know that a useful solution would be separate the execution in two files. First execute the document that contains the macro, and then reload the document with the information generated in the previous document.
But I still want to do it in the same doucment, I think it would be cooler ;).
Hope you can give me some advices about that.
Many thanks in advance!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How about using the document OnOpen event to execute the macro? You would need to be able to identify from within the macro when the action should be fired as it will fire every time (including user access) which you can do by passing a variable and value through the command line interface using the /v switch.
Regards,
Gordon

- « Previous Replies
-
- 1
- 2
- Next Replies »