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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Time since Macro has run

Hi there,

Im aware you can create a text box to display the time since a report has been Reloaded, is it possible to display the time a Macro was last run?

Many Thanks

Gerard

2 Replies
Not applicable
Author

Within the macro you could output the date/time to a file that gets loaded by the script. If you append to the file then use 'max' to get the most recent.

This is some macro code I use to record when some data is exported, which should give you some ideas:

set doc=ActiveDocument

vExportLog = doc.Variables("vExportLog").GetContent.String ' get log name

set fso = CreateObject("Scripting.FileSystemObject")

on error resume next

set logFile = fso.GetFile(vExportLog)

if err <> 0 then ' file does not exist
on error goto 0
set logFile = fso.CreateTextFile(vExportLog)
set logFile = fso.GetFile(vExportLog)
else
on error goto 0
end if

set txsStream = logFile.OpenAsTextStream(8) ' append
txsStream.WriteLine Now & " " & vExportTo & " created by " & doc.GetProperties.FileName
txsStream.WriteLine Now & " " & vExportTo_1 & " created by " & doc.GetProperties.FileName
txsStream.Close

Regards,

Gordon

johnw
Champion III
Champion III

I'd think you'd just set a variable to now() in the macro or as a separate action along with the macro trigger. The time since the macro was last run is interval(Variable-now()). But yeah, if you want that number preserved even when exiting and reentering the application, you'd probably need to fiddle with something like Gordon suggests.