Guest User

Nanotech Libreoffice Calc Csv Macro v1.0

a guest
Apr 8th, 2023
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1.  
  2. REM ***** BASIC *****
  3. ' tested on Libreoffice Calc 7.5.1.2 (x86_64) build:fcbaee479e84c6cd81291587d2ee68cba099e129 on Windows 10;
  4. ' It saves the current document and exports a csv copy to the same folder as the saved document;
  5. ' CSV delimters are ';' and text as "; on line: Propval(1).Value ="59,34,0,1,1" 'ASCII 59 = ; 34 = ";
  6. ' Name of file is the sheet name, this macro also exports all sheets you have on the ods file.
  7.  
  8. Sub Save_and_Export_Csv
  9. document = ThisComponent
  10. ThisComponent.Store
  11. GlobalScope.BasicLibraries.loadLibrary("Tools")
  12. FileDirectory = Tools.Strings.DirectoryNameoutofPath(document.getURL(), "/")
  13. Sheets = document.Sheets
  14. NumSheets = Sheets.Count - 1
  15. Dim Propval(1) as New com.sun.star.beans.PropertyValue
  16. Propval(0).Name = "FilterName"
  17. Propval(0).Value = "Text - txt - csv (StarCalc)"
  18. Propval(1).Name = "FilterOptions"
  19. Propval(1).Value ="59,34,0,1,1" 'ASCII 59 = ; 34 = ";
  20. For I = 0 to NumSheets
  21. document.getCurrentController.setActiveSheet(Sheets(I))
  22. Filename = FileDirectory + "/" + Sheets(I).Name + ".csv"
  23. FileURL = convertToURL(Filename)
  24. document.StoreToURL(FileURL, Propval())
  25. Next I
  26. End Sub
  27.  
Advertisement
Add Comment
Please, Sign In to add comment