View Single Post
 
Old 09-28-2020, 06:45 AM
hassinrasool hassinrasool is offline Windows 10 Office 2010
Novice
 
Join Date: Sep 2020
Posts: 2
hassinrasool is on a distinguished road
Default How do you add a line from a fillable word document into a VBA that you are using to email out

Hi everyone,

How do you add a line from a fillable word document into a VBA that you are using to email out that said document?

I have a VBA but I want to enter the name of the person completing the form from a line in the form into the body text of the email. (if that makes sense)

my VBA is:

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.Save

With EmailItem
.Subject = "Referral"
Dim sMsgBody As String
sMsgBody = sMsgBody & "Dear Team" & vbCr & vbCr
sMsgBody = sMsgBody & "Please find attached my completed referral form for a woman to your services" & vbCr & vbCr
sMsgBody = sMsgBody & "Kind Regards," & vbCr
.body = sMsgBody
.To = "person@person.com"
.Importance = 1
.Attachments.Add Doc.FullName
.Send

End With

Application.ScreenUpdating = True

Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing

End Sub
Reply With Quote