Option Explicit Sub ExportAllSheetsToCSV() Const BASE_PATH As String = "/media/matt1up/SanDiskX4tb/BRING-WITH-ME/HUMAN-DISPOSAL/07__Spreadsheets/03__Csv_Outputs" ' <--- EDIT TO YOUR DIR Dim oDoc As Object, oSheets As Object, oSheet As Object Dim oController As Object Dim nSheets As Long, i As Long Dim sSheetName As String Dim sDir As String Dim sFilePath As String, sURL As String Dim args(2) As New com.sun.star.beans.PropertyValue ' Normalize directory: ensure trailing slash sDir = BASE_PATH If Right(sDir, 1) <> "/" Then sDir = sDir & "/" End If ' Make sure this is a Calc doc oDoc = ThisComponent If Not oDoc.supportsService("com.sun.star.sheet.SpreadsheetDocument") Then MsgBox "Active document is not a Calc spreadsheet." Exit Sub End If oSheets = oDoc.Sheets nSheets = oSheets.getCount() oController = oDoc.getCurrentController() ' CSV filter options args(0).Name = "FilterName" args(0).Value = "Text - txt - csv (StarCalc)" ' UTF-8, comma, quote, etc. (your dialog settings) args(1).Name = "FilterOptions" args(1).Value = "44,34,76,1,,0,false,true,true,false" args(2).Name = "Overwrite" args(2).Value = True ' Loop over all sheets For i = 0 To nSheets - 1 oSheet = oSheets.getByIndex(i) ' Skip our helper sheet if present If oSheet.Name <> "ColWidths" Then ' Activate sheet so only this one is exported oController.ActiveSheet = oSheet ' Build filename from sheet name sSheetName = oSheet.Name sSheetName = Replace(sSheetName, "/", "_") sSheetName = Replace(sSheetName, "\", "_") sSheetName = Replace(sSheetName, " ", "_") sFilePath = sDir & sSheetName & ".csv" sURL = ConvertToURL(sFilePath) oDoc.storeToURL(sURL, args()) End If Next i MsgBox "All sheets exported to CSV in:" & Chr(10) & sDir End Sub