Hi everyone, I’m trying to make a macro to save LibreOffice sheets in CSV every 2 minutes. I set this macro so that I can save the sheets but it gives me an error on repetition. I think it’s because of application.ontime
. I used it with xls, but I can’t understand if there is an alternative and what it is. I’ve been going on google for days.
This is the error:
Application.OnTime Now + TimeValue("00:00:30"), "ExportToCsv": Errore di runtime BASIC. Object variable not set
Anyone can help me?
This is the code:
Sub ExportToCsv
document = ThisComponent
' Use the global string tools library to generate a path to save each CSV
GlobalScope.BasicLibraries.loadLibrary("Tools")
FileDirectory = Tools.Strings.DirectoryNameoutofPath(document.getURL(), "/")
' Work out number of sheets for looping over them later.
Sheets = document.Sheets
NumSheets = Sheets.Count - 1
' Set up a propval object to store the filter properties
Dim Propval(1) as New com.sun.star.beans.PropertyValue
Propval(0).Name = "FilterName"
Propval(0).Value = "Text - txt - csv (StarCalc)"
Propval(1).Name = "FilterOptions"
Propval(1).Value ="44,34,0,1,1" 'ASCII 44=, 59 = ; 34 = "
For I = 0 to NumSheets
' For each sheet, assemble a filename and save using the filter
document.getCurrentController.setActiveSheet(Sheets(I))
Filename = FileDirectory + "/" + Sheets(I).Name + ".csv"
FileURL = convertToURL(Filename)
document.StoreToURL(FileURL, Propval())
Next I
Call aggiornamento
End Sub
Sub aggiornamento()
Application.OnTime Now + TimeValue("00:00:30"), "ExportToCsv"
End Sub