Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-27-2023, 02:51 PM
JoeFreeman JoeFreeman is offline Help with submit button to email form Windows 10 Help with submit button to email form Office 2007
Novice
Help with submit button to email form
 
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
  #2  
Old 01-28-2023, 05:20 PM
Guessed's Avatar
Guessed Guessed is offline Help with submit button to email form Windows 10 Help with submit button to email form Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Why is it important to leave that document 'unfilled out'? You literally did a SaveAs to a temp folder so that the original doc is already in its original state.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help to get a word document to send specific content via email using submit button ActualJax Word VBA 2 07-06-2020 04:18 PM
Help with submit button to email form Submit Button Req that populates email address phorsley Word VBA 1 10-17-2017 04:50 PM
Infopath PDF attached to Form not showing in Email Submit CliffEstel Misc 0 09-20-2016 11:04 AM
Submit to Email Command Button rob7676 Word VBA 0 08-20-2015 05:05 AM
Help with submit button to email form VBA Code for a SUBMIT button in a Word form BlueMax Word VBA 3 08-07-2013 06:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft