[Solved] VBA: How to send document as an attachment

  • I know that in excel I can use this command to email the current workbook as an attachment:


    Application.Dialogs(xlDialogSendMail).Show


    Is there an equivalent for a Word macro?


    Thanks in advance,
    Damian

  • Hi Damian,


    The equivalent is Activedocument.sendmail , But it does not take arguments as in XL.


    Another alternative would be to use the routing slip.


    Code
    Sub Macro1()
        ActiveDocument.HasRoutingSlip = True
        With ActiveDocument.RoutingSlip
            .Subject = "Subject"
            .AddRecipient "[email protected]"
            .Delivery = wdAllAtOnce
        End With
        ActiveDocument.Route
    End Sub


    Although this has restrictions, like you can not change the default body text.


    The other alternative is to control the mail client via code.


    Cheers
    Andy

    [h4]Cheers
    Andy
    [/h4]

  • Thanks for your input Andy, but silly me - all I needed to do was record the macro action, and it gave me this:


    Code
    Options.SendMailAttach = True
    ActiveDocument.SendMail


    And that does exactly what I want.


    Damian.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!