Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM ***** BASIC *****
- ' tested on Libreoffice Calc 7.5.1.2 (x86_64) build:fcbaee479e84c6cd81291587d2ee68cba099e129 on Windows 10;
- ' It saves the current document and exports a csv copy to the same folder as the saved document;
- ' CSV delimters are ';' and text as "; on line: Propval(1).Value ="59,34,0,1,1" 'ASCII 59 = ; 34 = ";
- ' Name of file is the sheet name, this macro also exports all sheets you have on the ods file.
- Sub Save_and_Export_Csv
- document = ThisComponent
- ThisComponent.Store
- GlobalScope.BasicLibraries.loadLibrary("Tools")
- FileDirectory = Tools.Strings.DirectoryNameoutofPath(document.getURL(), "/")
- Sheets = document.Sheets
- NumSheets = Sheets.Count - 1
- 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 ="59,34,0,1,1" 'ASCII 59 = ; 34 = ";
- For I = 0 to NumSheets
- document.getCurrentController.setActiveSheet(Sheets(I))
- Filename = FileDirectory + "/" + Sheets(I).Name + ".csv"
- FileURL = convertToURL(Filename)
- document.StoreToURL(FileURL, Propval())
- Next I
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment