I had had recently discussed several similar cases with another community member and we found several different reasons. So it's important that sheets and objects will activated each time, that WaitForIdle and Sleep statements are implemented to avoid that some parts will be execute before others are finished.
But this won't help in each case - sometimes there are conflicts with the clipboard by which sometimes content will be lost or even added - very strange but sometimes it happend. Helpful could be to clear the clipboard and/or the cache from qlikview:
or depending on the used RAM:
For Each o in GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select FreePhysicalMemory from Win32_OperatingSystem")
memory_size = o.FreePhysicalMemory
if memory_size < 3000000 then