Envoi plage de cellule par mail

bonjour voici le code qui fonctionne sans pièce jointe. je souhaiterais y insérer en pj la feuil1 A1:E47

Private Sub CommandButton1_Click()

Dim OutApp As Object
Dim OutMail As Object
Dim Nom_Fichier As String
Dim add1 As String
Dim add2 As String
Dim add3 As String
Dim add4 As String
Dim add5 As String
Dim add6 As String
Dim add As String

Set OutApp = CreateObject("outlook.application")
Set OutMail = OutApp.CreateItem(0)

If CheckBox1 = True Then add1 = ""
If CheckBox2 = True Then add2 = ""
If CheckBox3 = True Then add3 = ""
If CheckBox4 = True Then add4 = ""
If CheckBox5 = True Then add5 = ""
If CheckBox6 = True Then add6 = ""
If CheckBox7 = True Then add7 = ""

    With OutMail
        .to = add1 & add2 & add3 & add4 & add5 & add6 & add7
        .CC = ""
        .bcc = ""
        .Subject = "Planning convoi funéraire"

        .display 'ou alors utiliser .Send
    End With
    On Error GoTo 0

Unload Me

End Sub

Merci a vous

Bonjour Julien35000

Pour exporter une plage en fichier PDF

Sub TestExportAsFixedFormat()
  ' For information about the final parameter, see this page:
  ' http://msdn.microsoft.com/en-us/library/aa338206.aspx

  Dim rng As Range
  Set rng = Range("A1:E10")
  ' SetupRangeData rng

  Dim fileName As String
  ' Change this file name to meet your own needs:
  fileName = "C:\Temp\Export.pdf"

  ' Many of these properties are optional, and are included
  ' here only to demonstrate how you might use them. The
  ' Type parameter can be one of xlTypePDF and xlTypeXLS;
  ' the Quality parameter can be one of xlQualityStandard and
  ' xlQualityMinimum. Setting the OpenAfterPublish property
  ' to True fails if you do not have a default viewer
  ' installed and configured.

  rng.ExportAsFixedFormat Type:=xlTypePDF, _
   fileName:=fileName, Quality:=xlQualityStandard, _
   IncludeDocProperties:=True, IgnorePrintAreas:=True, _
   From:=1, To:=1, OpenAfterPublish:=True
End Sub

Il ne te reste plus qu'à l'adapter pour joindre le fichier à ton mail

A+

bonsoir

cela beug avec la formule

Re,

Qu'elle formule !?

Que vous avez affiche.

Re,

Ce n'est pas une formule, mais du code VBA

Il faut mettre un apostrophe devant la ligne

SetupRangeData rng

il s'agit d'un commentaire et non d'une instruction

A+

Bonjour julien35000,

je reconnais mon bout de code posté hier......

je mets une pièce jointe, ça sera plus clair pour ceux qui seraient intéressés

il ne s'affiche pas en piece jointe directement dans le mail


bonjour Ednoork

Effectivement pour le code il vient de votre fichier

Merci pour l'aide sa fonctionne très bien.

Je souhaiterais ajouter une phrase dans le texte du mail es ce possible?

tu rajoutes .body

    With OutMail
        .to = add1 & add2 & add3 & add4 & add5 & add6
        .CC = ""
        .bcc = ""
        .Attachments.Add (sRep & "\" & sNomFic)
        .Subject = "Planning convoi funéraire"
        .body = "Texte à rajouter"
        .display 'ou alors utiliser .Send
    End With

oui merci c'est ce que je venais de faire et sa fonctionne j'avais un doute c'est parfait.

Merci


j'ai essayer a la place du mail envoyer en fax mais impossible a trouver de solution

Rechercher des sujets similaires à "envoi plage mail"