Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
@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
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