Bonjour à tous
J'obtiens un phénomène bien étrange sous excel
Une application access sur un réseau: CCV database.mdb
Une feuille excel sur chaque poste: biologie_CCV.xls
J'active un code dans access qui exécute du code dans une feuille excel.
Code dans access:
Code dans EXCEL:
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 Private Sub activation_Click() Dim appexcel As Excel.Application Dim wbexcel As Excel.Workbook 'ouvre la feuille excel "biologie_CCV.xls" Set appexcel = CreateObject("Excel.Application") appexcel.Visible = True Set wbexcel = appexcel.Workbooks.Open("C:\Documents and Settings\t86REA1\Bureau\biologie_CCV") 'execute du code dans un module excel "copie()" appexcel.Run ("copie") 'renseigne quelques champs sur la feuille excel appexcel.Sheets("M_GDS").Select appexcel.Cells(2, 1) = Me![ID_Réanimation] appexcel.Sheets("GDS").Select appexcel.Cells(1, 2) = Forms!F_Rea_long!Nom_Patient & " " & Forms!F_Rea_long!Prénom.Value appexcel.Sheets("M_GDS").Select appexcel.Sheets("GDS").Select End Sub
Chaque code marche bien. Mais quand je l'exécute depuis access, la page excel est figée et je ne peux que la fermer avec la croix. Quand je réouvre la feuille excel, tout s'est bien déroulé. Si je rajoute dans access:
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
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 copie() Dim acImport Dim c, firstAddress As Variant Dim fichier As String Dim MaBase As Object Dim var As Integer Application.ScreenUpdating = False Sheets("M_GDS").Select Cells.Select Selection.Copy Sheets("F_GDS").Select Range("A1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("A1").Select With Worksheets("F_GDS").Range("a1:q156") var = 0 Set c = .Find(var, LookIn:=xlValues, Lookat:=xlWhole) If Not c Is Nothing Then firstAddress = c.Address Do If c.Address(0, 0) = "Q156" Then Exit Do Else c.Value = "" Set c = .FindNext(c) On Error Resume Next Loop While Not c Is Nothing And c.Address <> firstAddress End If End With 'Défini ma base access et mon fichier excel Set MaBase = GetObject("\\Chu06nas1\n06ane2\CCV database_be.mdb") fichier = ActiveWorkbook.FullName 'transfère les données vers la table access On Error GoTo Error_Export: MaBase.DoCmd.TransferSpreadsheet acImport, 8, "T_GDS", fichier, True, "F_GDS!" 'un peu de nettoyage pour ne garder que la première colonne de GDS Sheets("GDS").Select Range("B1:EZ150").Select Selection.ClearContents Sheets("F_GDS").Select Cells.Select Selection.ClearContents Sheets("GDS").Select Range("B1").Select MsgBox "Exportation des données est effectuée correctement.", vbInformation, "Exportation": Exit Sub Error_Export: MsgBox "Attention, un problème est survenu pendant l'exportation, merci de vérifier les données.", vbExclamation, "ERREUR Exportation": Exit Sub End Sub
la feuille excel se ferme aprés la confirmation de l'enregistrement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 appexcel.quit
Existe-il une fonction actualisation ou requery dans excel ? Peut-être cela débloquerait excel
Merci d'avance pour vos suggestions
N.B: j'espère que le code n'est pas trop mal présenté !
Partager