Save Form, attach to email, close and don't save original form RRS feed

  • Question

  • I have never used VBA code before and have been asked to create a form with a command button that can attach the form to an email and close the form without saving so it can be used by the next person.  Here is what I have so far:

    Private Sub CommandButton1_Click()
    Dim OL As Object
    Dim EmailItem As Object
    Dim Doc As Document
    Application.ScreenUpdating = False
    Set OL = CreateObject("Outlook.Application")
    Set EmailItem = OL.CreateItem(olMailItem)
    Set Doc = ActiveDocument
    With EmailItem
      .Subject = "Special Teams Join or Resign Form"
      .Body = "" & vbCrLf & _
        "" & vbCrLf & _
      .To = ""
      .Attachments.Add Doc.FullName

    End With
    Application.ScreenUpdating = True
    Set Doc = Nothing
    Set OL = Nothing
    Set EmailItem = Nothing

    End Sub

    Thanks so much

    • Edited by MElissa116 Wednesday, October 8, 2014 4:14 PM
    Wednesday, October 8, 2014 4:11 PM

All replies

  • Ok you might open a Template so they can fill out the Form, then Save the filled out Form and run the code to get the saved doc in Outlook, and you are good to go.

    I am not sure if that's what you are asking, if not, please specify exactly what you need.

    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"

    Please vote an answer helpful if they helped. Please mark an answer(s) as an answer when your question is being answered.

    Wednesday, October 8, 2014 6:07 PM