J'ai actuellement une macro que je lance et qui me scanne mes fichiers CSV pour me les placer dans un second fichier (1 fichier par onglet).
Code : Tout sélectionner
Sub collectCSV
Const FILTER_NAME = "Text - txt - csv (StarCalc)"
Const FILTER_OPTIONS = "44,34,33,0,,0,false,false,true,false,false"
Dim sPath As String, sFileName As String, sSheetName As String
Dim oDoc As Variant, oSheets As Variant, oSheet As Variant
GlobalScope.BasicLibraries.LoadLibrary("Tools")
oDoc = CreateNewDocument("scalc")
oSheets = oDoc.getSheets()
sPath = CurDir
sPath = InputBox ("Please enter a folder name:","Source folder", sPath)
sFileName = Dir(sPath + getPathSeparator + "*.csv",0)
Do
sSheetName = CheckNewSheetname(oSheets, _
GetFileNameWithoutExtension(sFileName, getPathSeparator))
oSheets.insertNewByName(sSheetName,0)
oSheet = oSheets.getByName(sSheetName)
oSheet.link(ConvertToURL(sPath + getPathSeparator + sFileName), _
sSheetName, FILTER_NAME, FILTER_OPTIONS, _
com.sun.star.sheet.SheetLinkMode.VALUE)
oSheet.setLinkMode(com.sun.star.sheet.SheetLinkMode.NONE)
sFileName = Dir()
Loop Until sFileName = ""
msgbox thiscomponent.currentController.activeSheet.name
End Sub
Pas moyen de changer son nom ...
Code : Tout sélectionner
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///C:/sortie/Synthèse.ods"
args1(1).Name = "FilterName"
args1(1).Value = "calc8"
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1())
Une idée ?
Merci