• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 519
  • Last Modified:

Refer to a field on a Word document in an email send from the documetn

I have a word form user fill out.  there is a data entried field called Client_Name. I need to have this in the title of an email, but how do I tell the code to grab this information?  I can get the email to work, but not the text information.

Private Sub CommandButton1_Click()
Dim olApp As Object
Dim olMsg As Object
Dim Doc  As Document
Dim fField As FormField
Dim objField As Object

''' strField = Fields.FieldName = "Client_Name"
Set objField = Doc.FormFields("Client_Name").TextInput.Va

Set olApp = CreateObject("Outlook.Application")
Set olMsg = olApp.CreateItem(0)
Set Doc = ActiveDocument

With olMsg
.To = "mwawro@firstrepublic.com"
''' .Subject = "Wire Tracer" & Doc.FormFields(0)
.Subject = "Wire Tracer" & objField
.Body = "Please review"
.Attachments.Add Doc.FullName
End With

Set olMsg = Nothing
Set olApp = Nothing

End Sub
  • 2
1 Solution
David Johnson, CD, MVPOwnerCommented:
tell the code to grab this information

Where is it going to be coming from, contact information, email address i.e.
John Doe <john.doe@example.com>, a database?
What kind of field are you using?

Not sure what this line is: Set objField = Doc.FormFields("Client_Name").TextInput.Va

try changing .Subject = "Wire Tracer" & objField

.Subject = "Wire Tracer" & objField.code OR
.Subject = "Wire Tracer" & objField.result
ssmith94015Author Commented:
Actually discovered the control was a ContextControl and I needed to use that syntax.  It was not a FormField!  thank you all for the advise, but once I discovered that, I could enter the correct code.

ssmith94015Author Commented:
It was a ContextControl not a FormField.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now