Fermeture / Crash? Excel sans confirmation quand double clic
Bonjour à tous,
Je n'ai pas trop l'habitude de poster des messages sur des forums car le plus souvent la plus grande majorité des problèmes que j'ai rencontrés ont déjà trouvé leur solution, or là je bloque et surtout je ne comprends pas.
J'ai mis en place une macro qui lors d'un double clic sur un tableau structuré ouvre une page internet contenant des informations en référence au contenu de la case en question.
Voici déjà mon module pour internet :
Option Explicit
Public Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub OuvrirClient(gichet As String, ref As String)
Dim Fichier As String
Fichier = "blablabla"& gichet & " blablabla" & ref
ShellExecute 0, "", Fichier, "", "", 0
End Sub
Sub OuvrirCA(gichet As String)
Dim Fichier As String
Fichier = "blablabla" & gichet & "blablabla"
ShellExecute 0, "", Fichier, "", "", 0
End SubEt voici le code sur ma Feuil1 :
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim ligne As Integer, col As Integer, i As Integer
Dim idEntreprise As Integer, idGerant As Integer, idGichet As String, idRef As String
Dim nom As String, prenom As String, entreprise As String, telF As String, telP As String, email As String
idGerant = 0
i = 0
If Not Application.Intersect(Target, Columns("C")) Is Nothing Then
ligne = ActiveCell.Row
col = ActiveCell.Column
idEntreprise = Cells(ligne, col - 1).Value
While idEntreprise <> idGerant
idGerant = Feuil2.Cells(5 + i, 2)
i = i + 1
Wend
i = i - 1
prenom = (Feuil2.Cells(5 + i, 3))
nom = Feuil2.Cells(5 + i, 4)
entreprise = UCase(Feuil2.Cells(5 + i, 5))
telF = Format(Feuil2.Cells(5 + i, 6), "0# ## ## ## ##")
telP = Format(Feuil2.Cells(5 + i, 7), "0# ## ## ## ##")
email = Feuil2.Cells(5 + i, 8)
If MsgBox("Id : " & idEntreprise & Chr(10) & "Prenom : " & prenom & Chr(10) & "Nom : " & UCase(nom) & Chr(10) & "Entreprise : " & entreprise & Chr(10) & "Tel Fixe : " & telF & Chr(10) & "Tel Pro : " & telP & Chr(10) & "Email : " & email, vbQuestion) = vbOK Then
End If
End If
If Not Application.Intersect(Target, Columns("E")) Is Nothing Then
ligne = ActiveCell.Row
col = ActiveCell.Column
idGichet = Cells(ligne, col + 1).Value
idRef = Cells(ligne, col).Value
If MsgBox("Voulez-vous ouvrir la fiche client?", vbYesNo + vbInformation, "Fiche Client") = vbYes Then
OuvrirClient idGichet, idRef
End If
End If
If Not Application.Intersect(Target, Columns("G")) Is Nothing Then
ligne = ActiveCell.Row
col = ActiveCell.Column
idGichet = Cells(ligne, col - 1).Value
If MsgBox("Voulez allez blablabla : " & idGichet & Chr(10) & "blablablablabla." & Chr(10) & "Voulez-vous continuer ?", vbYesNo + vbInformation, "Fiche Client") = vbYes Then
OuvrirCA idGichet
End If
End If
MsgBox ("coucou !")
End
End SubTout se passe bien si je double clic sur ma colonne C, pareil pour la E, mais SI je double clic sur la colonne G alors tout se déroule bien mais après m'avoir affiché "coucou" dans ma msgbox, excel se ferme sans rien demander à personne.
Je ne comprends pas, aucune erreur, aucune confirmation de clôture, rien ....
Je suis dans un impasse je ne comprend pas ce qui se passe, quelqu'un aurait-il une suggestion?
Merci d'avance !
[EDIT] : L'erreur ne survient (la fermeture) que si je double clic sur le tableau, dans le reste de la colonne, certes la page web (du coup) affiche un lien invalide, mais l'Excel survit et ne se ferme pas.
[EDIT] : L'erreur survient sur certaines colonnes du tableau mais pas sur toute 3/11 pour être précis.
[EDIT] : Problème résolu; Il fallait rajouter :
Cancel = TrueAu moins maintenant c'est stable ! VOILA ! Petite astuces a tout ceux qui utiliserez (comme moi) les fonctions before double clic sans rien maitriser.
La bise au forum