View Single Post
 
Old 09-09-2018, 11:50 PM
stu_c stu_c is offline Windows 8 Office 2013
Novice
 
Join Date: Dec 2013
Posts: 20
stu_c is on a distinguished road
Default VBA Code For Submit Button

Hi all
I have got a submit button on my word document that once clicked sends to a specific Email, is it possible that once clicked the button disappears and shows Form Submitted?

my current code is.

Code:
Private Sub SubmitButton1_Click()
Label1.Visible = True
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.Save
 
With EmailItem
    .Subject = "Form submited"
    .Body = ""
    .To = "none@none.com"
    .Importance = olImportanceNormal
    .Attachments.Add Doc.FullName
    .Send
End With
 
Application.ScreenUpdating = True
 
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub
Reply With Quote