Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sifatnabil
Specialist
Specialist

Task Scheduler does not work with macro

Hi all,

I have a batch file setup on Windows Task Scheduler which works fine with the following code in the batch file:

echo off

echo.

echo Initialize the log file with Command Line reload...

echo Run QlikView and Reload Data...

"C:\Program Files (x86)\QlikView\Qv.exe" /r "C:\Users\bob\Dashboard.qvw"

However, the same batch file does not work if the Qlikview document has a macro that is triggered OnOpen. What might the issue be?

18 Replies
mohammadkhatimi
Partner - Specialist
Partner - Specialist

hie...

.bat file contains below code...

@ECHO OFF

"C:\Program Files\QlikView\qv.exe" /r "Path of your qlikview file"

ECHO Application Reload Completed!

Batch file is been schedule in task schedular..At what time you have to reload..

Hope this will help you

Regards,

Mohammad

sifatnabil
Specialist
Specialist
Author

Hi, it doesn't work if the Qlikview document has a macro triggered OnOpen.

jerrysvensson
Partner - Specialist II
Partner - Specialist II

It should work. What happens?

sifatnabil
Specialist
Specialist
Author

Nothing happens actually. It just says "Running". If I double click the batch file though, it works. Just not through Windows Task Scheduler. Are there any alternative task schedulers I could try out?

jerrysvensson
Partner - Specialist II
Partner - Specialist II

If you remove all actions from OnOpen does it work then?

Also, if Task scheduler runs on a different account then yours it needs a license, That is probably the issue here,

rohit214
Creator III
Creator III

try this

"C:\Program Files (x86)\QlikView\Qv.exe;" /r "C:\Users\bob\Dashboard.qvw;"

sifatnabil
Specialist
Specialist
Author

Well it works with the other batch file, so license is not an issue. If I remove OnOpen, how do I make the Qlikview doc automatically run the macro?

jerrysvensson
Partner - Specialist II
Partner - Specialist II

Ok

Well it might be something in your macro that stops the loading process.

Can you give us the code?

sifatnabil
Specialist
Specialist
Author

Sure, I used the code to send PDF reports via email:

Sub Bonds

vReport = "RP19" 'Set report

vName = "Bonds" 'Name of output pdf

ActiveDocument.PrintReport(vReport), "Bullzip PDF Printer", false 'Printreport

reportFile = "Z:\Reporting\PDF Reports\" & vName &".pdf" 'Setting outputname

MyPrintPDFWithBullZip(reportFile) 'Call pdf printer

ActiveDocument.GetApplication.Sleep 5000

zendDagrapportBonds

End sub

function zendDagrapportBonds()

Dim objEmail

Const cdoSendUsingPort = 2 ' Send the message using SMTP

Const cdoAnonymous = 0 'Do not authenticate

Const cdoBasic = 1 'basic (clear-text) authentication

Const cdoNTLM = 2 'NTLM

SMTPServer = "XXXX"

Const SMTPPort = 25 ' Port number for SMTP

Const SMTPTimeout = 60 ' Timeout for SMTP in seconds

'Sending mail

Set objEmail = CreateObject("CDO.Message")

Set objConf = objEmail.Configuration

Set objFlds = objConf.Fields

With objFlds

'---------------------------------------------------------------------

' SMTP server details

.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort

.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer

.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous

.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort

.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = SMTPTimeout

.Update

'---------------------------------------------------------------------

End With

vName = "Bonds"

vName2 = "CDS"

strbody = "Hi Lee/Grant" & vbNewLine & vbNewLine

objEmail.To = "sifat" 'Email Recipient

objEmail.From = "sifat" 'Email Sender

objEmail.cc = "sifat"

objEmail.Subject = "Desk Report" ' Subject

objEmail.TextBody = strbody

objEmail.AddAttachment "Z:\Reporting\PDF Reports\" & vName &".pdf" ' Attachement

objEmail.AddAttachment "Z:\Reporting\PDF Reports\" & vName2 &".pdf" ' Attachement

objEmail.Send

Set objFlds = Nothing

Set objConf = Nothing

Set objEmail = Nothing

end function


FUNCTION MyPrintPDFWithBullZip (pdfOutputFile)

set obj = CreateObject("Bullzip.pdfSettings")

obj.PrinterName = "Bullzip PDF Printer"

obj.SetValue "Output" , pdfOutputFile

obj.SetValue "ConfirmOverwrite", "no"

obj.SetValue "ShowSaveAS", "never"

obj.SetValue "ShowSettings", "never"

obj.SetValue "ShowPDF", "no"

obj.SetValue "RememberLastFileName", "no"

obj.SetValue "RememberLastFolderName", "no"

obj.SetValue "ShowProgressFinished", "no"

obj.SetValue "ShowProgress", "no"

obj.WriteSettings True

END FUNCTION