CommandButton n'est plus lié au code
* Bonjour, *
Mon bouton de commande ne fonctionne plus.
Je n'ai rien fait de particulier, juste l'insertion d'une image sur ce bouton.
Est-ce lié ?
Je n'ai rien suspecté dans les propriétés de l'objet.
Le bouton est actif mais ne semble plus lié au code.
Merci d'avance pour votre aide.
Code:
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
| 'envoi d'un email aux destinataire de la feuil2 d'excel
Private Sub CommandButton5_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim tableauDestinataires() As String
Dim nbDestinataires As Integer
Dim strbody As String
nbDestinataires = 0
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("E").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "G").Value) = "oui" Then
ReDim Preserve tableauDestinataires(nbDestinataires)
tableauDestinataires(nbDestinataires) = cell.Value
nbDestinataires = nbDestinataires + 1
End If
Next cell
Set OutMail = OutApp.CreateItem(0)
strbody = "Dear all," & OutMail.Subject & Chr$(13) & vbNewLine & vbNewLine & _
"Please find attached the shipping documents" & vbNewLine & _
"" & vbNewLine & _
"- Invoice with Packing list" & vbNewLine & _
"- Certificate of Analysis" & vbNewLine & _
"" & vbNewLine & _
"Best regards"
On Error Resume Next
With OutMail
.To = tableauDestinataires
.Subject = "Order"
'.Body = "Dear all,"
.Body = strbody & vbNewLine & vbNewLine
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub |