How to apply a button to send email with current Word file attached?

If you find yourself frequently sending emails from a Word document via Outlook and attaching the current Word file, you can streamline this process by creating a custom button. This button allows you to send an email with a simple click, eliminating the need to open Outlook separately. In this article, I’ll guide you through a quick and easy solution.

Applying the “Send Email with Current Word File Attachment” Button:

Follow these steps within your Word document:

  1. First, create a command button by clicking on Developer > Legacy Tools > Command Button (ActiveX Control), as shown in the screenshot:

  2. Select the button and click on Properties in the Developer tab. In the Properties pane, enter the desired caption text in the Caption field, as shown in the screenshot:

  3. Close the Properties pane. Right-click on the button and choose View Code:

  4. In the Microsoft Visual Basic for Applications window, copy and paste the following code into the middle of the existing commands:

    Dim xOutlookObj As Object
    Dim xEmail As Object
    Dim xDoc As Document

    Application.ScreenUpdating = False
    Set xOutlookObj = CreateObject(“Outlook.Application”)
    Set xEmail = xOutlookObj.CreateItem(olMailItem)
    Set xDoc = ActiveDocument

    xDoc.Save

    With xEmail
    .Subject = “Fax-data”
    .Body = “This is a test email.”
    .To = “yy@addin99.com”
    .Importance = olImportanceNormal
    .Attachments.Add xDoc.FullName
    .Display
    End With

    Set xDoc = Nothing
    Set xEmail = Nothing
    Set xOutlookObj = Nothing

    Application.ScreenUpdating = True

    Note: Modify the subject, body, or recipient’s address in the code according to your preferences.

  5. Save and close this code window. Press Design Mode to exit design mode. Now, when you click the button you created, an email will be generated with the current Word document attached, as shown below:

    How to apply a button to send email with current Word file attached

    How to apply a button to send email with current Word file attached

  6. Finally, click Send to dispatch this email.

By following these steps, you’ve successfully added a button to your Word document, providing a convenient way to send emails with the current document attached.

We will be happy to hear your thoughts

Leave a reply

Gotkey.net
Logo
Compare items
  • Total (0)
Compare
0
Shopping cart