Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

qv.exe /R sometimes runs OnPostReload macro, sometimes doesn't?

Has this issue happened to anyone else? I have a QVW that run a OnPostReload() and when reloaded via qv.exe /R it doesn't always run. When reloaded "manually" it works perfect. Anyone have any suggestions?

1 Solution

Accepted Solutions
Not applicable
Author

What I do is assigning the macro to a button (call it BU01 for example).

Then create the following vbs code:

Set MyApp = CreateObject("QlikTech.QlikView")
Set MyDoc = MyApp.OpenDoc ("C:\test\toto.qvw","","")
Set ActiveDocument = MyDoc
ActiveDocument.Reload
ActiveDocument.GetSheetObject("BU01").Press

Set MyDoc = Nothing
MyApp.Quit
Set MyApp = Nothing

This will open the document then reload then run the macro.

Then the document is closed.

In Publisher you can then create an external command task.

Rgds,

Sébastien

View solution in original post

8 Replies
Not applicable
Author

so anyone know why this can be happening?

Not applicable
Author

I never trust the trigger as I have experienced the same problem. I use one of two methods:

1) After the reload with a /R I then invoke the document again passing a variable with a specific value using the /V switch. I have a macro that runs as the OnOpen trigger and if the variable value is as per the passed value, it runs some code. I wrap these 2 lines in a .bat file.

CALL "C:\PROGRAM FILES\QLIKVIEW\QV.EXE" /R "E:\QVApplications\QVCustomers\CUSTOMER SEGMENTATION.QVW"
CALL "C:\PROGRAM FILES\QLIKVIEW\QV.EXE" /VvExport=1 "E:\QVApplications\QVCustomers\CUSTOMER SEGMENTATION.QVW"

2) Create an alert that runs On Post Reload in batch mode to send an email if something unusual was detected in the load script (such as a file not found)

Hope this helps,

Gordon

Not applicable
Author

regards solution 1) the macro is like this:

sub ExportData

set doc=ActiveDocument

vExport = doc.Variables("vExport").GetContent.String

if vExport = "1" then

......

doc.GetApplication.Quit

end if

end sub

Not applicable
Author

What I do is assigning the macro to a button (call it BU01 for example).

Then create the following vbs code:

Set MyApp = CreateObject("QlikTech.QlikView")
Set MyDoc = MyApp.OpenDoc ("C:\test\toto.qvw","","")
Set ActiveDocument = MyDoc
ActiveDocument.Reload
ActiveDocument.GetSheetObject("BU01").Press

Set MyDoc = Nothing
MyApp.Quit
Set MyApp = Nothing

This will open the document then reload then run the macro.

Then the document is closed.

In Publisher you can then create an external command task.

Rgds,

Sébastien

Not applicable
Author

thanks spastor, it works perfectly. Big Smile

Not applicable
Author

Sébastien,

Your code is working great but OpenDoc() is using the QV window that is currently opened. Is there a way to instantiate a new QV window? Thanks.

Not applicable
Author

problem : can't set macro to allow system access from RELOAD (option /r not work)

Ref : http://community.qlik.com/message/18973

Ref : http://community.qlik.com/message/21833

Ref :       http://community.qlik.com/message/165717

1.Create Batch file  ==> "C:\Program Files\QlikView\qv.exe" /l "path_to_document"

2.Create Task Scheduler to RUN Batch file (1)

3.QVW Document ==> Document properties > OnPostReload ==> Add RUN MACRO

4.add  (end of script)

       ActiveDocument.Save

   Application.Quit

don't forget

1. User Preference >Security > select "Module..." and "File.."

2. Document Properties > Security > Macro Override Security

tdupasqu
Contributor II
Contributor II

Thanks for this useful summary! Switching from qv.exe /r to /l fixed it for me.