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
|
Private Sub btn_browser1_Click()
Dim fd As Office.FileDialog
' Créer un objet FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
' Titre de la boîte de dialogue
fd.Title = "Sélectionnez l'export SAP 1- Reste à livrer mode ALV..."
' Ne pas autoriser la sélection multiple
' (donc 1 seul fichier est sélectionnable à la fois)
fd.AllowMultiSelect = False
' Définir les types de fichiers autorisés en ajoutant un filtre
fd.Filters.Clear
fd.Filters.Add "Fichiers Excel", "*.xls; *.xlsx"
' Présélectionner le filtre
fd.FilterIndex = 0
' Afficher la boîte de dialogue
If fd.Show() Then
Me.txt_path1 = fd.SelectedItems(1)
End If
Set fd = Nothing
End Sub
Private Sub btn_browser2_Click()
Dim fd As Office.FileDialog
' Créer un objet FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
' Titre de la boîte de dialogue
fd.Title = "Sélectionnez l'export SAP 2- Situation commandes et livraisons..."
' Ne pas autoriser la sélection multiple
' (donc 1 seul fichier est sélectionnable à la fois)
fd.AllowMultiSelect = False
' Définir les types de fichiers autorisés en ajoutant un filtre
fd.Filters.Clear
fd.Filters.Add "Fichiers Excel", "*.xls; *.xlsx"
' Présélectionner le filtre
fd.FilterIndex = 0
' Afficher la boîte de dialogue
If fd.Show() Then
Me.txt_path2 = fd.SelectedItems(1)
End If
Set fd = Nothing
End Sub
Private Sub btn_browser3_Click()
Dim fd As Office.FileDialog
' Créer un objet FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
' Titre de la boîte de dialogue
fd.Title = "Sélectionnez l'export SAP 3- Reste à livrer Interdiv..."
' Ne pas autoriser la sélection multiple
' (donc 1 seul fichier est sélectionnable à la fois)
fd.AllowMultiSelect = False
' Définir les types de fichiers autorisés en ajoutant un filtre
fd.Filters.Clear
fd.Filters.Add "Fichiers Excel", "*.xls; *.xlsx"
' Présélectionner le filtre
fd.FilterIndex = 0
' Afficher la boîte de dialogue
If fd.Show() Then
Me.txt_path3 = fd.SelectedItems(1)
End If
Set fd = Nothing
End Sub
Private Sub btn_browser4_Click()
Dim fd As Office.FileDialog
' Créer un objet FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
' Titre de la boîte de dialogue
fd.Title = "Sélectionnez l'export SAP 4- OTD Interdiv..."
' Ne pas autoriser la sélection multiple
' (donc 1 seul fichier est sélectionnable à la fois)
fd.AllowMultiSelect = False
' Définir les types de fichiers autorisés en ajoutant un filtre
fd.Filters.Clear
fd.Filters.Add "Fichiers Excel", "*.xls; *.xlsx"
' Présélectionner le filtre
fd.FilterIndex = 0
' Afficher la boîte de dialogue
If fd.Show() Then
Me.txt_path4 = fd.SelectedItems(1)
End If
Set fd = Nothing
End Sub
Private Sub btn_import_Click()
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
'Ouverture de l'application
Set appExcel = CreateObject("Excel.Application")
'Ouverture d'un fichier Excel
Set wbExcel = appExcel.Workbooks.Open(Me.txt_path1)
Set wbExcel = appExcel.Workbooks.Open(Me.txt_path2)
Set wbExcel = appExcel.Workbooks.Open(Me.txt_path3)
Set wbExcel = appExcel.Workbooks.Open(Me.txt_path4)
'wsExcel correspond à la première feuille du fichier
Set wsExcel = wbExcel.Worksheets(1)
DoCmd.TransferSpreadsheet acImport, 8, "Nomtabled'import1", Me.txt_path1, True
DoCmd.TransferSpreadsheet acImport, 8, "Nomtabled'import2", Me.txt_path2, True
DoCmd.TransferSpreadsheet acImport, 8, "Nomtabled'import3", Me.txt_path3, True
DoCmd.TransferSpreadsheet acImport, 8, "Nomtabled'import4", Me.txt_path4, True
DoCmd.SetWarnings False
DoCmd.OpenQuery "Ajout Nomtableendur1"
DoCmd.OpenQuery "Ajout Nomtableendur2"
DoCmd.OpenQuery "Ajout Nomtableendur3"
DoCmd.OpenQuery "Ajout Nomtableendur4"
DoCmd.OpenQuery "Maj Nomtableendur1"
DoCmd.OpenQuery "Maj Nomtableendur2"
DoCmd.OpenQuery "Maj Nomtableendur3"
DoCmd.OpenQuery "Maj Nomtableendur4"
DoCmd.OpenQuery "Suppr Nomtabled'import1"
DoCmd.OpenQuery "Suppr Nomtabled'import2"
DoCmd.OpenQuery "Suppr Nomtabled'import3"
DoCmd.OpenQuery "Suppr Nomtabled'import4"
DoCmd.SetWarnings True
Me.Requery
End Sub |
Partager