Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
vmonitor
Contributor III
Contributor III

Failed to open file in write mode for file *.csv

I have a script that runs every 3 minutes. Sometimes it stops at night due to the fact that it is impossible to write the file ("Failed to open file in write mode for file list.csv"). I know that the most likely reason for this is the backup. How can I change my macro for recording files to work around the problem?

Sub ExportToCSV

set obj= ActiveDocument.GetSheetObject("LB04")
obj.Export "E:\Qlik\list.csv",","
End Sub

2 Replies
Brett_Bleess
Former Employee
Former Employee

@vmonitor This is not really a question for this forum, as what you want to do is 'system' level function, not a QlikView API call as far as I can see, so your best bet would be to search the Microsoft Forums in this case I believe to see if you can find what you need over there.  The best solution would likely be to exclude that file from backup routine and manually do that task if you need a copy of it, or if you have Publisher, maybe setup a Supporting Task External Program task that would do the backup via copy/paste etc...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
marcus_sommer

You may add some logic to check if this file exists or if the file is locked before you export your csv. Like @Brett_Bleess mentioned would here the MS vbs/vba forum more appropriate to get examples how it could be done.

Another approach would to be to implement an error-handling and because of the fact that your export is triggered every 3 minutes you won't really need a query for err.number to decide / to branch what should be done in the case of an error else probably it's enough to skip the error. This means something like this:

Sub ExportToCSV

set obj= ActiveDocument.GetSheetObject("LB04")
On Error Resume Next
obj.Export "E:\Qlik\list.csv",","
End Sub

- Marcus