I'm having an issue with saving qvw files from a macro. I have many files that refresh on a daily scheduler by using multiple bat files. Sometime files get locked up. Not the same ones each time and not the same bat file. It seems very random at this point. At the end of my macro I have the following code.
I always get the "Before Save" log entry. Somehow qlikview is hanging on the ActiveDocument.Save. The qvw file timestamp indicates that the save did happen but it fails to return from the function. Therefore qlikview just stays open in the backgroud and the bat file doesn't continue. If I kill the qlikview process then the bat file will continue. Clearly that does not work well in a situation that needs to be fully automated though. Some nights all bat files will complete without any stopping and other nights some are hung up because of this issue. It's becoming a real problem so if anyone can suggest something I can do to fix it or a way to debug what is really going on I would really appreciate it.
Why do you want to save the qvw with a macro. Can't you just schedule a task on your server to reload the qvw? Or why not using the save as icon that QlikView provide? Can't figure out why you need that macro. Can you explain it better?
The reload is started from a bat file on our staging server. The macro is set to run OnPostReload and is needed to make a bunch of default selections and then it saves the file and quits QV. Then the bat file will upload the file to the webserver. For some reason the ActiveDocument.Save is not returning from the function. Sometimes it's many hours before it's noticed so there is no way it's just slow or anything.
Normally this approach worked well. I use the same since years (in former days for everything and today only for automatism export- and print-jobs). In the beginning I struggeled with simalar problems which was caused from a file-locking through the windows shadow copy services. I found this reason through an analysing from the windows event log which I recommend for you to use. I think you will find there noticeable hints.
An workaround might be to use a small routine which checked if the file is locked and/or save the file in a recursive loop or use a SaveAs statement and drop the original and rename the new one or something similar - but before I would look on the event-logs.
Another point could be an instable network or storage (only windows systems are supported - no NAS) and/or a lack on system-ressources (CPU + RAM).
Thank you for the reply. I will check out the event-logs to see if there are any clues there. Storage is on a local disk so I shouldn't have any issue there. As for system resources this server has 274GB of RAM and I've never seen it go over 20% usage. CPU on the other hand is often over 80% to 98% used when 5 bat files are running at once. I'll do some further investigations and tests.