Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
stabben23
Partner - Master
Partner - Master

Reload from macro fails randomly

Hi, I have a problem which have bothered me for awhile.

I have a Dashboard which I save as a png file and save it to a path. This Works, but it fails randomly during the day. If I'm Lucky it could Works 24 hours, but sometimes it fails 2 times in 10 min.

The logfile says Execution finished, script runs to the end but then something happens. This Message shows up and the Application need to be restarted.

execution.GIF

This is the code that I use in edit module:

Sub RefreshData
'Reload new data
ActiveDocument.ReloadEX 0,1

'Export sheet

ActiveDocument.GetSheetByID("SH02").Activate
ActiveDocument.GetApplication.WaitForIdle 1500
ActiveDocument.GetSheetByID("SH02").ExportBitmapToFile "\\10.1.1.1\xxx\xxx\xxx\pic.png"
ActiveDocument.GetApplication.WaitForIdle 3000
ActiveDocument.Save
End Sub

I have try to export to local path C:\temp but still same problem.

17 Replies
cwolf
Creator III
Creator III

Use WaitForIdle without milliseconds!

Sub RefreshData

    'Reload new data

    ActiveDocument.DoReload 2,false,false

    ActiveDocument.GetApplication.WaitForIdle

    ActiveDocument.Save

    ActiveDocument.GetApplication.WaitForIdle

    'Export sheet

    ActiveDocument.GetSheetByID("SH02").Activate

    ActiveDocument.GetApplication.WaitForIdle

    ActiveDocument.GetSheetByID("SH02").ExportBitmapToFile "c:\temp\pic.png"

End Sub

stabben23
Partner - Master
Partner - Master
Author

Thanks Christian,

I'll change and do a test.

What is the different between ActiveDocument.DoReload 2,false,false and ActiveDocument.ReloadEX 0,1?

cwolf
Creator III
Creator III

Description in QlikView API Guid:

DoReload:

Executes the script. This is a more modern version of the old Reload member. The old Reload will continue to work for most applications.

stabben23
Partner - Master
Partner - Master
Author

Seams like theese two are the same, no script window is shown during the reload.

cwolf
Creator III
Creator III

The progress dialog during reload you can see only with ReloadEx:

ActiveDocument.ReloadEx 2,2

stabben23
Partner - Master
Partner - Master
Author

Hi Christian,

The milliseconds seams to cause the problem that I have, I have now run the Application during the night and no issue at all. Do you know why these milliseconds are "bad"?

cwolf
Creator III
Creator III

After the milliseconds, the macro is continued regardless of whether the idle state has already been reached or not. For example, you can not export the chart before it is finished. Before such actions you have to wait for the idle state how long it will take. It needs a WaitforIdle after Reload, Save, Activate, ...

stabben23
Partner - Master
Partner - Master
Author

Many Thanks Christian,

I hve tested so many Things here but not "deleted" the milliseconds. I have rather increase the milliseconds to get rid of the problem.