Bonjour à tous,
L'accès à la base de donnée par Excel fonctionne.
j'utilise la macro suivante pour extraire des données Oracle, elle bloque à la ligne .Refresh BackgroundQuery:=False
Si quelqu'un peut m'aiguiller. Merci d'avance

Code vba : 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
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
Sub Lecture_base()
 
   base_de_donnees = "ODBC;DSN=TOP;UID=TOPERP;PWD=TOPERP;SERVER=TOP"
    '-------------------------------------------------------------------------
    ' lecture des parametres
    '-------------------------------------------------------------------------
 
 
    Sheets("resultat cycle").Select
    '------------------------------------------------------------------------------
    ' constitution du sql
    '-------------------------------------------------------------------------------
 
    'critere_1 = Cells(3, 2)
    'critere_2 = Cells(4, 2)
    'critere_3 = Cells(5, 2)
 
    texte_sql = " "
    For i = 1 To 50
      If Sheets("sql").Cells(i, 1) <> "" Then
         texte_sql = texte_sql & Sheets("sql").Cells(i, 1) & Chr(13) & Chr(10)
      End If
    Next i
 
    'texte_sql = Replace(texte_sql, "CRITERE_1", critere_1)
    'texte_sql = Replace(texte_sql, "CRITERE_2", critere_2)
    'texte_sql = Replace(texte_sql, "CRITERE_3", critere_3)
 
    Sheets("debug").Cells(1, 1) = texte_sql
 
    Range("A8:I2500").Select
'    Selection.QueryTable.Delete
    Selection.ClearContents
    Range("A8").Select
    'Cells(8, 1).Select
    'Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    'Selection.ClearContents
 
    With ActiveSheet.QueryTables.Add(Connection:= _
        base_de_donnees, Destination:=Range("A8"))
        .CommandText = texte_sql
        .Name = "Commandes fournisseurs"
        .FieldNames = False
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = False 'xlInsertDeleteCells
        .SavePassword = True
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .Refresh BackgroundQuery:=False
    End With
    Range("A6").Select
    Cells.Select
    Selection.Columns.AutoFit
    Range("A1").Select
End Sub