Bonjour,
Jusqu'à ce jour j'utilisais une macro pour importer sur excel une dizaine de fichiers xml identiques.
Un nouveau besoin se fait sentir pour importer maintenant, chaque semaine environ 1000 fichiers xml.
Je souhaite donc passer sur access.
J'ai adapté la macro excel et le problème est que :
1 / une table se crée à chaque fichier XML importé alors que je veux tout dans une table déjà existante
2 / la table se crée vide
Voila la macro :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Sub importxmldansaccess() DoCmd.OpenTable ("REJET") Dim xStrPath As String Dim xFileDialog As Office.FileDialog Dim xFile As String Dim xCount As Long 'On Error GoTo ErrHandler Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker) xFileDialog.AllowMultiSelect = False xFileDialog.Title = "Select a folder" If xFileDialog.Show = -1 Then xStrPath = xFileDialog.SelectedItems(1) End If If xStrPath = "" Then Exit Sub xFile = Dir(xStrPath & "\*.xml") Do While xFile <> "" Application.importxml _ datasource:=(xStrPath & "\" & xFile), _ importoptions:=acappendata xFile = Dir() Loop 'ErrHandler: ' MsgBox "no files xml", , " " End Sub
Partager