Note: The other languages of the website are Google-translated. Back to English
登入  \/ 
x
or
x
註冊  \/ 
x

or

如何應用按鈕發送帶有當前Word文件的電子郵件? 

如果您需要通過Outlook從Word文檔發送電子郵件,並附加當前的Word文件,則可以創建命令按鈕,然後通過單擊此按鈕發送消息而無需打開Outlook。 本文,我將介紹如何快速,輕鬆地處理它。

應用按鈕以發送帶有當前Word文件的電子郵件


應用按鈕以發送帶有當前Word文件的電子郵件

請執行以下步驟來解決Word文件中的這項工作:

1。 首先,您應該創建一個命令按鈕,請單擊 開發人員 > 舊版工具 > 命令按鈕(ActiveX控件),請參見屏幕截圖:

doc按鈕發送電子郵件1

2。 選擇按鈕,然後單擊 氟化鈉性能開發人員 標籤,在 氟化鈉性能 窗格中,將所需的標題文本輸入到 標題 字段,請參見屏幕截圖:

doc按鈕發送電子郵件2

3。 然後,關閉 氟化鈉性能 窗格,現在,右鍵單擊按鈕,然後選擇 查看代碼,請參見屏幕截圖:

doc按鈕發送電子郵件3

4。 然後,在顯示的 Microsoft Visual Basic for Applications 窗口,將以下代碼複製並粘貼到原始腳本之間,請參見屏幕截圖:

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

doc按鈕發送電子郵件4

備註:在上面的代碼中,您應該根據需要更改主題,正文或發送的地址。

5。 然後,保存並關閉此代碼,單擊 設計模式 關閉設計模式。 現在,單擊創建的命令按鈕時,將創建一封電子郵件,其中包含當前的Word文檔,請參見屏幕截圖:

doc按鈕發送電子郵件5

6。 最後,您只需要單擊 發送 按鈕發送此消息。


推薦的Word生產力工具

 

Kutools For Word - 100 多個 Word 高級功能,節省 50% 的時間

  • 複雜和重複的操作可以在幾秒鐘內完成一次處理。
  • 跨文件夾一次將多個圖像插入Word文檔。
  • 將文件夾中的多個Word文件合併並合併為所需順序。
  • 根據標題,分節符或其他條件將當前文檔拆分為單獨的文檔。
  • 在Doc和Docx之間,Docx和PDF之間轉換文件,用於常見轉換和選擇的工具集合等...
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Richard Bird · 7 days ago
    I have create the document but my issue  now is that if I send this form to say 4 people to complete, when they open it up from the email attachment it opens in read only mode and when they click submit it asks them to save as before it will allow the code to open an email addressed to me. Is there a way around this other than giving them the location of the file?
  • To post as a guest, your comment is unpublished.
    Chelo · 10 months ago
    Hi Extend office,

    Can we set a different email not linked to Outlook? Like direct email to GoDaddy account?

    • To post as a guest, your comment is unpublished.
      Shelby · 5 months ago
      I am trying to find out the same information. I use gmail and I need to create a form to send out to varies different email address that can automatically submit back to my gmail account. 

  • To post as a guest, your comment is unpublished.
    Jacques · 1 years ago
    Does this also work for Lotus Notes?
    What must I change in "xOutlookObj"?
  • To post as a guest, your comment is unpublished.
    Lasse Jensen · 1 years ago

    For example using text from a textbox/textfield in the Word-document, and inserting it as text in the subject line of your E-mail?

    • To post as a guest, your comment is unpublished.
      Mark Crane · 7 months ago
      Yes this is also what i'm after can anybody help with this request?
  • To post as a guest, your comment is unpublished.
    Gill Leadbetter · 1 years ago
    I'd like my document to send as a PDF document rather than a word document.

  • To post as a guest, your comment is unpublished.
    Santiago · 1 years ago
    Hi! I'd like to make the command button send an email with the Word document as the body of the email (my word document is a form). Is there a way to do that?
  • To post as a guest, your comment is unpublished.
    andrew · 1 years ago
    I had it working at first, and then for some reason now, it gives me an error of error 429 about activeX component can't create object. i literally just copied and pasted. This worked before but i just changed font size, made button bigger, and relabeled caption. i don't think i accidentally changed some other settings? any idea what it could be?
  • To post as a guest, your comment is unpublished.
    Tausif · 1 years ago
    I have made a fillable form in MS word. I have used legacy tools for calculation etc. I have also added a submit button which works to send the form to email. The problem is that when I reopen this document after saving, it does not work. I have even tried saving it as macro enabled document but no use. Can you please help ?
    Thanks
  • To post as a guest, your comment is unpublished.
    Don Patterson · 1 years ago
    Can this be done so you only send one page of a document?
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      Hello, Don,
      To deal with your task, please apply the below code,in the code, you should change the start page and end page to your own:

      Private Sub CommandButton1_Click()
      Dim xCurPageStart As Long, xCurPageEnd As Long, xCurPageRange As Range
      Dim xCurPage As Integer, xPages As Integer
      Dim xOutlookObj As Object
      Dim xEmail As Object
      Dim xDoc As Document, xNewDoc As Document
      Dim xFilePath As String
      Dim xOldStart As Long, xOldEnd As Long
      On Error Resume Next
      Application.ScreenUpdating = False
      Set xOutlookObj = CreateObject("Outlook.Application")
      Set xEmail = xOutlookObj.CreateItem(olMailItem)
      xFilePath = CreateObject("WScript.Shell").SpecialFolders(16)
      Set xDoc = ActiveDocument
      xOldStart = xDoc.Application.Selection.Start
      xOldEnd = xDoc.Application.Selection.End
      xDoc.Save
      xFilePath = xFilePath + "\attached file" + VBA.Mid(xDoc.FullName, VBA.InStrRev(xDoc.FullName, ".")) 'attached file is the attachment file name,change to your need
      xCurPageStart = 2 'start page
      xCurPageEnd = 2 'end page
      xPages = Selection.Information(wdNumberOfPagesInDocument)
      xCurPageStart = Selection.GoTo(what:=wdGoToPage, Which:=wdGoToNext, Name:=xCurPageStart).Start
      If xCurPage = xPages Then
      xCurPageEnd = ActiveDocument.Content.End
      Else
      xCurPageEnd = Selection.GoTo(what:=wdGoToPage, Which:=wdGoToNext, Name:=xCurPageEnd + 1).Start
      End If
      Set xCurPageRange = ActiveDocument.Range(xCurPageStart, xCurPageEnd)
      xCurPageRange.Select
      xCurPageRange.Copy
      Set xNewDoc = Application.Documents.Add(Visible:=False)
      xNewDoc.Activate
      xNewDoc.Content.PasteAndFormat wdFormatOriginalFormatting
      xNewDoc.SaveAs2 FileName:=xFilePath
      xNewDoc.Close
      xDoc.Range(xOldStart, xOldEnd).Select
      With xEmail
      .Subject = "Fax-data"
      .Body = "This is a test email."
      .To = "yy@addin99.com"
      .Importance = olImportanceNormal
      .Attachments.Add xFilePath
      .Display
      End With
      VBA.Kill xFilePath
      Set xDoc = Nothing
      Set xEmail = Nothing
      Set xOutlookObj = Nothing
      Application.ScreenUpdating = True
      End Sub
  • To post as a guest, your comment is unpublished.
    Abhi · 1 years ago
    Hi Extend Office Team,

    I believe 'xEmile' is misspelt. It should be 'xEmail'.

    While the code runs and there is no issue, the following statement will do nothing:

    Set xEmail = Nothing
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      Hi,Abhi,
      Thank you for your comment, as you said, the 'xEmile' is misspelt, it should be 'xEmail'. I have updated the code.
      Thank you again!
  • To post as a guest, your comment is unpublished.
    Alondra · 1 years ago
    Hola, me podrían apoyar para que el archivo se convierta en PDF y se adjunte al correo en ves del word por favor.
    Muchas gracias.
  • To post as a guest, your comment is unpublished.
    Nichole · 2 years ago
    I am trying to have the email send with the subject line being the contents of one of my fields. Is this possible?