Envoyer une feuille Excel par courriel

Bonjour,

J'essaie d'envoyer par courriel une feuille seulement ( en pièce jointe et non en corp de texte) d'un fichier excel qui en contient environ 15. Les feuilles doivent être envoyés chacune à une personne différente.

J'ai trouvé une macro (elle ne vient pas de moi ,,, pas encore arrivé là) Mais bon elle fonctionne bien mais elle ne me laisse pas le choix d'entrer l'adresse courriel de la personne à qui je veux la faire parvenir. Elle l'envoie par défaut à une adresse entré dans la macro. Est ce possible de faire ouvrir outlook et me laisser entrer l'adresse à qui je veux l'envoyé ? Merci , votre aide sera grandement apprécié !!!

Voici la macro

Sub Mail_ActiveSheet()
'Working in 2000-2010
    Dim FileExtStr As String
    Dim FileFormatNum As Long
    Dim Sourcewb As Workbook
    Dim Destwb As Workbook
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim OutApp As Object
    Dim OutMail As Object

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

    Set Sourcewb = ActiveWorkbook

    'Copy the sheet to a new workbook
    ActiveSheet.Copy
    Set Destwb = ActiveWorkbook

    'Determine the Excel version and file extension/format
    With Destwb
        If Val(Application.Version) < 12 Then
            'You use Excel 2000-2003
            FileExtStr = ".xls": FileFormatNum = -4143
        Else
            'You use Excel 2007-2010, we exit the sub when your answer is
            'NO in the security dialog that you only see  when you copy
            'an sheet from a xlsm file with macro's disabled.
            If Sourcewb.Name = .Name Then
                With Application
                    .ScreenUpdating = True
                    .EnableEvents = True
                End With
                MsgBox "Your answer is NO in the security dialog"
                Exit Sub
            Else
                Select Case Sourcewb.FileFormat
                Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
                Case 52:
                    If .HasVBProject Then
                        FileExtStr = ".xlsm": FileFormatNum = 52
                    Else
                        FileExtStr = ".xlsx": FileFormatNum = 51
                    End If
                Case 56: FileExtStr = ".xls": FileFormatNum = 56
                Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
                End Select
            End If
        End If
    End With

    '    'Change all cells in the worksheet to values if you want
    '    With Destwb.Sheets(1).UsedRange
    '        .Cells.Copy
    '        .Cells.PasteSpecial xlPasteValues
    '        .Cells(1).Select
    '    End With
    '    Application.CutCopyMode = False

    'Save the new workbook/Mail it/Delete it
    TempFilePath = Environ$("temp") & "\"
    TempFileName = "Part of " & Sourcewb.Name & " " _
                 & Format(Now, "dd-mmm-yy h-mm-ss")

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    With Destwb
        .SaveAs TempFilePath & TempFileName & FileExtStr, _
                FileFormat:=FileFormatNum
        On Error Resume Next
        With OutMail
            .To = "ron@debruin.nl"
            .CC = ""
            .BCC = ""
            .Subject = "This is the Subject line"
            .Body = "Hi there"
            .Attachments.Add Destwb.FullName
            'You can add other files also like this
            '.Attachments.Add ("C:\test.txt")
            .Send   'or use .Display
        End With
        On Error GoTo 0
        .Close SaveChanges:=False
    End With

    'Delete the file you have send
    Kill TempFilePath & TempFileName & FileExtStr

    Set OutMail = Nothing
    Set OutApp = Nothing

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
End Sub

Bonjour

Plus simple, pourquoi ne pas utiliser l'option disponible dans Fichier - > envoyer vers -> Destinataire ?

Si cela ne fonctionne pas, essaie avec ce code

Sub test
Activesheet.copy
Application.Dialogs(xlDialogSendMail).Show
End sub

Amicalement

Bonjour Dan,

Merci pour ta réponse rapide, je ne veux pas utiliser le envoyé vers destinataire car cette fonction envoi la feuille en dans le corps du message et je veux l,envoyer en pièce jointe.

Donc, le petit code que tu m'as envoyé fonctionne bien, mais est ce qu'on pourrais ajouter un texte dans le message par défaut?

Et supprimer automatiquement le fichier qui se crée lors de l'activation de la macro,une fois le message envoyé ?

Merci !!

Re,

Ok là il faut changer un peu le code. Quelle est la messagerie utilisée ??

Amicalement

Bonjour,

Il s'agit de Microsot Outlook ,

Merci!

Cat

re,

Sub Envoifeuillexl()
'Macro Dan - 09/05/2011
Dim fichier As String
Dim ol As New Outlook.Application
Dim olmail As MailItem
ThisWorkbook.ActiveSheet.Copy
With ActiveWorkbook
    fichier = .Name & ".xls"
    .SaveAs Filename:=ThisWorkbook.Path & "\" & fichier
    .Close
End With
Set ol = New Outlook.Application
Set olmail = ol.CreateItem(olMailItem)
With olmail
    .Subject = "sujet"
    .Attachments.Add ThisWorkbook.Path & "\" & fichier
    .Display
    '.Send
End With
Kill ThisWorkbook.Path & "\" & fichier
End Sub

NB : Avant d'utiliser cette macro, aller dans l'éditeur VBE (ALT + F11) et dans le menu / Outils / Reference --> Cocher "Microsoft Outlook object Library"

Amcialement

Bonjour,

Merci pour les codes , les deux fonctionne très bien,,

Rechercher des sujets similaires à "envoyer feuille courriel"