1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
| REM ***** BASIC *****
Sub ouvrirfichiercopiercellule
MsgBox("ATTENTION: lancement de l'importation des données d'un autre classeur")
MsgBox("Toujours faire une copie de sauvegarde (et la conserver) auparavant")
MsgBox("En cas de doute, abandonner la procédure et contacter votre ER-TICE")
Dim DocumentEnCours as object, FeuillesDocumentEnCours as object, MaFeuilleDocumentEnCours as object
Dim RepertoireURLNonConverti As object , ValeurRepertoireURLNonConverti As Integer , RepertoireURLConverti as string, oCurseurMaFeuilleDocumentEnCours as object, oCurseur2MaFeuilleDocumentEnCours as object
Dim ListeFichiersRepertoire As string , Resultat As String
Dim AdresseFichier as string
Dim ChoixFichiers As Object, LesFichiers As Object
Dim MonFic As string, Fic()As String, LeRep As String
ChoixFichiers = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
ChoixFichiers.DisplayDirectory = ConvertToURL("C:\Mes Documents\")'adapter le chemin
ChoixFichiers.appendFilter("Document ODF", "*.ods")';*.odt;*.odg;*.odp")'filtre les fichiers ODF
' ChoixFichiers.appendFilter("Texte" , "*.txt")'filtre les fichiers texte
If ChoixFichiers.execute = com.sun.star.ui.dialogs.ExecutableDialogResults.OK then
LesFichiers = ChoixFichiers.Files
MonFic = dir((LesFichiers(0))
'MsgBox(ChoixFichiers.DisplayDirectory,0,"Le Répertoire")
'MsgBox(LesFichiers(0),0,"Le Chemin")
'MsgBox(MonFic,0,"Le fichier")
End if
' a voir
Dim origDocument as object
Dim destDocument as object
Dim origDispatcher as object
Dim destDispatcher as Object
'pour les tableaux
Dim args(0) as new com.sun.star.beans.PropertyValue
Args(0).name="Hidden"
Args(0).value=true
Dim props(0) as new com.sun.star.beans.PropertyValue
Dim Array(5) as new com.sun.star.beans.PropertyValue
Array(0).Name = "Flags"
Array(0).Value = "S" Rem S= String V= Value D= Date
Array(1).Name = "FormulaCommand"
Array(1).Value = 0
Array(2).Name = "SkipEmptyCells"
Array(2).Value = false
Array(3).Name = "Transpose"
Array(3).Value = false
Array(4).Name = "AsLink"
Array(4).Value = false
Array(5).Name = "MoveMode"
Array(5).Value = 0
dim args3(6) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Flags"
args3(0).Value = "SV"
args3(1).Name = "FormulaCommand"
args3(1).Value = 0
args3(2).Name = "SkipEmptyCells"
args3(2).Value = false
args3(3).Name = "Transpose"
args3(3).Value = false
args3(4).Name = "AsLink"
args3(4).Value = false
args3(5).Name = "MoveMode"
args3(5).Value = 4
args3(6).Name = "Annotation"
args3(6).Value = 1
DocumentEnCours = ThisComponent 'Sélectionne le document en cours
FeuillesDocumentEnCours=DocumentEnCours.sheets ' les feuilles du classeur
' destination
destDocument = ThisComponent.CurrentController.Frame
destDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
AdresseFichier=(LesFichiers(0))
oDesktop = createUnoService( "com.sun.star.frame.Desktop" )
cURL = ConvertToURL( AdresseFichier )
oDoc = oDesktop.loadComponentFromURL(cURL , "_Blank", 0, args() )
origDocument = oDoc.CurrentController.Frame
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Ecoles
'MaFeuilleDocumentEnCours = FeuillesDocumentEnCours.GetByName("Ecoles")
'oCurseurMaFeuilleDocumentEnCours = MaFeuilleDocumentEnCours.createCursor ' création du curseur
'MaFeuilleDocumentEnCours.getCellByPosition(21,((10-1+(X*20)))).string = AdresseFichier ' on écrit en B5 feuille1 (0,X) ou x = 1 au départ puis 2 3 4 5 .....
'MaFeuilleDocumentEnCours.getCellByPosition(4,(x+8)).string = DDE("soffice";(RepertoireURLConverti+"\"+ListeFichiersRepertoire);FICHE_ECOLE_A_remplir.B8)
'MaFeuilleDocumentEnCours.getCellByPosition(20,((10-1+(X*20)))).string = ListeFichiersRepertoire
' copie des infos "Ecoles" partie 1-------------------
MsgBox("Copie de Ecoles partie1")
' à l'origine pas avant mais ça origDocument = ThisComponent.CurrentController.Frame
origDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
props(0).Name = "ToPoint"
props(0).Value = "Ecoles.$A4:$D57"
origDispatcher.executeDispatch(origDocument, ".uno:GoToCell", "", 0, props())
origDispatcher.executeDispatch(origDocument, ".uno:Copy", "", 0, Array())
props(0).Name = "ToPoint"
props(0).Value = "Ecoles.$A4:$D57"
destDispatcher.executeDispatch(destDocument, ".uno:GoToCell", "", 0, props())
destDispatcher.executeDispatch(destDocument, ".uno:InsertContents", "", 0, args3())
' copie des infos "Ecoles" partie 2-------------------
MsgBox("Copie de Ecole partie2")
' à l'origine pas avant mais ça origDocument = ThisComponent.CurrentController.Frame
origDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
props(0).Name = "ToPoint"
props(0).Value = "Ecoles.$J4:$AC57"
origDispatcher.executeDispatch(origDocument, ".uno:GoToCell", "", 0, props())
origDispatcher.executeDispatch(origDocument, ".uno:Copy", "", 0, Array())
props(0).Name = "ToPoint"
props(0).Value = "Ecoles.$J4:$AC57"
destDispatcher.executeDispatch(destDocument, ".uno:GoToCell", "", 0, props())
destDispatcher.executeDispatch(destDocument, ".uno:InsertContents", "", 0, args3())
'- copie des infos par ITR-------------------
MsgBox("Copie de ITR ")
origDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
props(0).Name = "ToPoint"
props(0).Value = "ITR.$B3:$E48"
origDispatcher.executeDispatch(origDocument, ".uno:GoToCell", "", 0, props())
origDispatcher.executeDispatch(origDocument, ".uno:Copy", "", 0, Array())
props(0).Name = "ToPoint"
props(0).Value = "ITR.$B3:$E48"
destDispatcher.executeDispatch(destDocument, ".uno:GoToCell", "", 0, props())
destDispatcher.executeDispatch(destDocument, ".uno:InsertContents", "", 0, args3())
'- copie de septembre-------------------
MsgBox("Copie de septembre ")
origDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
props(0).Name = "ToPoint"
props(0).Value = "sep.$D5:$BA37"
origDispatcher.executeDispatch(origDocument, ".uno:GoToCell", "", 0, props())
origDispatcher.executeDispatch(origDocument, ".uno:Copy", "", 0, Array())
props(0).Name = "ToPoint"
props(0).Value = "sep.$D5:$BA37"
destDispatcher.executeDispatch(destDocument, ".uno:GoToCell", "", 0, props())
destDispatcher.executeDispatch(destDocument, ".uno:InsertContents", "", 0, args3())
End Sub |
Partager