Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro not working when reloading from command line

Hi all,

this is a very weird situation.

I have a simple script to export a csv file that is called  when OnPostReload event is fired.

Sub ExportToCSV

  set sObject1 = ActiveDocument.GetSheetObject("ClientiUnivoci")

  sObject1.Export "Output\ClientiUnivoci_Week_" & Year(Now()) & LPad(Month(Now()),"0",2 ) & LPad(Day(Now()),"0",2 ) & ".csv", ";", 65001

End Sub

When I launch reload inside qlikview the script works fine and the file is generated, when I lanch qlikview reload from a batch file using the following command:

"C:\Program Files\QlikView\Qv.exe" /r "C:\Qlikview\Project\LastWeek.qvw"

the qlikview file is reload but the macro is not executed and the csv file is not generated.

I made the following attemps without success:

  • "C:\Program Files\QlikView\Qv.exe" /r /NoSecurity "C:\Qlikview\Project\LastWeek.qvw"
  • Settings | Document Properties | Security -> All checked except Allow Print, Show All Sheets and Objects and Show Progress for Hidden Script
  • Settings | User preferences | Security -> All checked except Confirm Launch from Macro
  • Tools | Edit Module | Request Module Security -> System Access
  • Tools | Edit Module | Current Local Security -> Allow System Access
  • Run batch as Administrator

I don't really know what to do more.

Do you have any ideas?

Thanks in advance.

Nicola


13 Replies
Not applicable
Author

Yes exactly, I double click on the .bat file with the goal of inserting it in a scheduled task.

I use the same approach since years too, but I never faced a case like this. I'm working on it since yesterday evening but I still haven't found a solution...

marcus_sommer

It sounds stupid now but try to change the trigger maybe to OnOpen, replace the routine with a simple msgbox or selection-action, create a complete new qvw with a small inline-table and a tablebox and use your export-routine again (something files get corrupted), further trial and error ...

Have you those app created himself or it's from another person maybe even downloaded from a server or mailed to you - sometimes windows creates flags for this which could prevent an remote-execution.

Not applicable
Author

Finally I resolved the issue!!!!! Qlikview doesn't care about a relative path if the reload is executed inside the application. If the reload is executed externally from a command line you need to insert the full path in the script:

WRONG SCRIPT:

Sub ExportPercentileSettimana

          set sObject2 = ActiveDocument.GetSheetObject("Percentile")

          sObject2.ExportBiff "Output\Percentile_Week_" & Year(Now()) & LPad(Month(Now()),"0",2 ) & LPad(Day(Now()),"0",2 ) & ".xls"        

End Sub

RIGHT SCRIPT:

Sub ExportPercentileSettimana

          set sObject2 = ActiveDocument.GetSheetObject("Percentile")

          sObject2.ExportBiff "C:\Users\sarnic\Documents\Progetti\Aperti\Project\Sviluppo\Report\Output\Percentile_Week_" & Year(Now()) & LPad(Month(Now()),"0",2 ) & LPad(Day(Now()),"0",2 ) & ".xls"        

End Sub

Hope this may help someone  else.

Thanks to everyone.

Nicola

marcus_sommer

Mostly it are the small things ...