View Single Post
 
Old 01-27-2023, 02:51 PM
JoeFreeman JoeFreeman is offline Windows 10 Office 2007
Novice
 
Join Date: Jan 2023
Posts: 1
JoeFreeman is on a distinguished road
Default Help with submit button to email form

Hi,
I found a code that works to email a document back to me but it saves the document in the filled out state. Is there a way to clear the document after sending? 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
Doc.SaveAs FileName:=Environ("temp") & "" & Environ("username"), Fileformat:=wdFormatDocument, AddToRecentFiles:=True
With EmailItem
.Subject = "New Tool Request"
.Body = "" & vbCrLf & _
"" & vbCrLf & _
""
.To = ""
.Importance = olImportanceHigh
.Attachments.Add Doc.FullName
.Display
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing

End Sub
Reply With Quote