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
|
Dim src_form, name_form As String
Dim i, j As Integer
Dim objAccess As Access.Application
Set objAccess = New Access.Application
i = 0
Do Until i = Me.Liste0.ItemsSelected.Count
Dim database As String
name_form = Me.Liste0.Column(0, Me.Liste0.ItemsSelected(i))
Dim obj As AccessObject
Dim temp As String
If Me.Liste0.Column(1, Me.Liste0.ItemsSelected(i)) = "Formulaire" Then
temp = ""
Set objAccess = New Access.Application
With objAccess
.OpenCurrentDatabase path, False
End With
For Each obj In objAccess.Application.CurrentProject.AllForms
If obj.name = name_form Then
temp = name_form
End If
Next obj
If Not temp = "" Then
objAccess.Application.DoCmd.DeleteObject acForm, temp
End If
objAccess.Quit
Set objAccess = Nothing
DoCmd.TransferDatabase acExport, "Microsoft Access", path, acForm, name_form, name_form
Else
If Me.Liste0.Column(1, Me.Liste0.ItemsSelected(i)) = "Etat" Then
temp = ""
Set objAccess = New Access.Application
With objAccess
.OpenCurrentDatabase getFullDbPath, False
End With
For Each obj In objAccess.Application.CurrentProject.AllReports
If obj.name = name_form Then
temp = name_form
End If
Next obj
If Not temp = "" Then
objAccess.Application.DoCmd.DeleteObject acDefault, temp
End If
objAccess.Quit
Set objAccess = Nothing
DoCmd.TransferDatabase acExport, "Microsoft Access", path, acReport, name_form, name_form
Else
temp = ""
Set objAccess = New Access.Application
With objAccess
.OpenCurrentDatabase getFullDbPath, False
End With
For Each obj In objAccess.Application.CurrentData.AllQueries
If obj.name = name_form Then
temp = name_form
End If
Next obj
If Not temp = "" Then
objAccess.Application.DoCmd.DeleteObject acQuery, temp
End If
objAccess.Quit
Set objAccess = Nothing
DoCmd.TransferDatabase acExport, "Microsoft Access", path, acQuery, name_form, name_form
End If
End If
i = i + 1
Loop
MsgBox "Exportation réussie", vbOKOnly
Exit Sub |
Partager