Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
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.

1 Solution

Accepted Solutions
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

View solution in original post

17 Replies
avinashelite

If the script execution is complete then the problem is some time its not able to save the document this may happen because of the server not available , memory etc

share the complete log file

stabben23
Partner - Master
Partner - Master
Author

Hi Avinash,

this is not used in a server environment, its my local desktop‌. Its not a memory issue and there is no log file except the document logfile which not include any issues.

avinashelite

could you share the document log file ?  every day is it failing at the same time ? 

stabben23
Partner - Master
Partner - Master
Author

It fails randomly, not the same time. I show you a screenshoot from my log files, they always look like this, no difference in it. The script is always succeeded

logfile_hy.GIF

avinashelite

Do you have any other process running because if your creating QVD 's and if its open by other qvw it won't allow you to save .

one more thing I suspect is , during the failure time check your Antivirus is running because few antivirus does allow QV to perform operations ..

stabben23
Partner - Master
Partner - Master
Author

No qvd's, it export a png file to a folder path.

Antivirus could be Worth a check.

avinashelite

also check during that time whether the image is open by others or by any app

Hope this helps you

stabben23
Partner - Master
Partner - Master
Author

I have also notice that when I press "Yes" the macro will continue to export the Picture.

It feel like the macro end here:

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

Then When I press Yes the rest of the macro run then Application die.

execution.GIF

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

stabben23
Partner - Master
Partner - Master
Author

That was my first Guess, but when I change path to my local computer (C:\Temp\) it stills crash.