Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-28-2020, 06:45 AM
hassinrasool hassinrasool is offline How do you add a line from a fillable word document into a VBA that you are using to email out Windows 10 How do you add a line from a fillable word document into a VBA that you are using to email out Office 2010
Novice
How do you add a line from a fillable word document into a VBA that you are using to email out
 
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
  #2  
Old 09-28-2020, 08:04 AM
gmaxey gmaxey is online now How do you add a line from a fillable word document into a VBA that you are using to email out Windows 10 How do you add a line from a fillable word document into a VBA that you are using to email out Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

What are you using as the "fillable" field? If you use as content controls titles say "Author" then you could use:

Code:
sMsgBody = sMsgBody & "Please find attached my completed referral form for a woman to your services" & vbCr & vbCr
     sMsgBody = sMsgBody & "Kind Regards," & vbCr
sMsgBox = sMsgBody & Doc.SelectContentControlsByTitle("Author").Item(1).Range.Text

     .body = sMsgBody
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 09-29-2020, 01:41 AM
hassinrasool hassinrasool is offline How do you add a line from a fillable word document into a VBA that you are using to email out Windows 10 How do you add a line from a fillable word document into a VBA that you are using to email out Office 2010
Novice
How do you add a line from a fillable word document into a VBA that you are using to email out
 
Join Date: Sep 2020
Posts: 2
hassinrasool is on a distinguished road
Default

@gmaxey
Thank you for this, I was using content controls so I changed the tag to author.
It didn't work initially but noticed you had a typo (smsgbox) that I changed and works perfectly
Reply With Quote
  #4  
Old 10-03-2020, 10:13 AM
Charles Kenyon Charles Kenyon is offline How do you add a line from a fillable word document into a VBA that you are using to email out Windows 10 How do you add a line from a fillable word document into a VBA that you are using to email out Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

I believe that "Author" is the name of a built-in Document Property Content Control that you could use instead. See Repeating Data Using Document Properties Content Controls and Other Mapped Content Controls.
It is filled with whatever would normally show up in the Author Document Property unless changed. On my documents, it is my Word username by default.


You could also get that name from the system if you do not want it changed by the user.
Reply With Quote
Reply

Tags
vba word outlook email

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a fillable word template but not see what is not req'd to be filled in saved as document sjohnstone@edgeautomation Word 1 05-02-2017 10:05 AM
How do you add a line from a fillable word document into a VBA that you are using to email out Protect fillable word 2013 document metsmaniac Word 1 06-30-2016 12:35 PM
How do you add a line from a fillable word document into a VBA that you are using to email out Word 2010 - How to create a fillable document from a boilerplate document sheaters Word 2 05-04-2016 01:57 PM
How do you add a line from a fillable word document into a VBA that you are using to email out How to make uneditable but fillable document in word 2003? officeboy09 Word 1 01-22-2014 03:54 PM
How do you add a line from a fillable word document into a VBA that you are using to email out Put a document in word into a fillable form groovy chick Word 3 01-18-2012 04:49 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:24 AM.


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