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
| 'Procédure qui permet d'extraire les données de la base Zotra via un Query
Private Sub extraction_dqy(flag, chemin_fichier_dqy, fichier_dqy, param1, param2, param3, param4, chemin_base_access, chemin_fichier_model, fichier_model, requete)
'On intègre dans les variables (xlodbc, num, base, res) les différentes informations à injecter dans le DQY par la suite
xlodbc = "XLODBC"
num = 1
base = "DSN=MS Access Database;DBQ=" & chemin_base_access & ";DefaultDir=" & chemin_fichier_model & ";DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
If flag = 0 Then
res = "EXEC " & requete & " '" & param1 & "','" & param2 & "'"
ElseIf flag = 1 Then
res = "EXEC " & requete & " '" & param1 & "','" & param2 & "','" & param3 & "','" & param4 & "'"
End If
'On intègre les informations dans le fichier DQY
'For Output As permet, à l'ouverture du fichier DQY de supprimer sont contenus et d'intégrer les nouvelles informations
intFic = FreeFile
Open chemin_fichier_dqy & fichier_dqy For Output As intFic
Print #intFic, xlodbc
Print #intFic, num
Print #intFic, base
Print #intFic, res
Close intFic
If flag = 0 Then
'On lance l'éxécution du fichier DQY
With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;" & chemin_fichier_dqy & fichier_dqy & "", _
Destination:=Range("A1"))
.Name = "saison"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
ElseIf flag = 1 Then
Sheets("feuil2").Select
'On lance l'éxécution du fichier DQY
With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;" & chemin_fichier_dqy & fichier_dqy & "", _
Destination:=Range("A1"))
.Name = "saison_histo"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=True
End With
End If
End Sub |
Partager