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
| Public xlApp As Excel.Application
Public xlBook As Excel.Workbook
Public xlsheet As Excel.Worksheet
Sub Ouv_Excel(Bidon)
'__________________
'
' Routine qui vérifie qu'Excel est ouvert
' et déclenche l'ouverture si fermé
On Error GoTo Trt_Erreur
Set xlApp = GetObject(, "Excel.Application")
'MsgBox ("Nom xlApp :" & xlApp.Name)
GoTo suite
Trt_Erreur:
'MsgBox ("Erreur")
Nom = ""
Set xlApp = CreateObject("Excel.Application")
Resume Next
suite:
On Error GoTo 0
End Sub
Sub Ouv_Classeur(Chemin_nom, Nom_Fichier)
'________________________________________
'
' Routine d'ouverture d'un fichier Excel
' (si il n'est pas déjà ouvert)
' Vérification de l'ouverture d'Excel
Call Ouv_Excel(Bidon)
' Vérification des classeurs déjà ouverts
N_Wb = xlApp.Workbooks.Count
Deja_Ouvert = False
If N_Wb <> 0 Then
For i_Wb = 1 To N_Wb
Wb_Name = xlApp.Workbooks(i_Wb).Name
'MsgBox (xlApp.Workbooks(i_Wb).Name)
If Nom_Fichier = Wb_Name Then
xlApp.Workbooks(i_Wb).Activate
xlApp.Visible = True
Deja_Ouvert = True
Exit Sub
End If
Next
End If
If Deja_Ouvert = False Then
' Ouverture du fichier
Nom_Long_Fichier = Chemin_nom & "\" & Nom_Fichier
Set xlBook = xlApp.Workbooks.Open(Nom_Long_Fichier)
xlApp.Visible = True
End If
End Sub |
Partager