View Single Post
 
Old 05-03-2017, 06:27 AM
nanders8 nanders8 is offline Windows 7 64bit Office 2010 32bit
Novice
 
Join Date: Aug 2014
Posts: 6
nanders8 is on a distinguished road
Default Assistance with Word VBA

I have a word document setup as a form. The users have to fill out the form then hit the Submit Email button at the bottom of the form. When they press this button, it will generate an email to a specific email address and attach the form to the email. I am wanting the subject to take and concatenate two fields from the form together. Everything is sort of working except for a couple of things.

When I submit the form the subject line reads as

GSS #390 for FORMTEXT NICHOLAS ANDERSON FORMTEXT 605-321-1181

Is there a way that I can remove the FORMAT text from the subject?

Here is the code that I am using:
Code:
Private Sub CommandButton1_Click()
Dim olkApp As Object
Dim strSubject As String
Dim strTo As String
Dim strBody As String
Dim strAtt As String

    strSubject = "GSS #390 for" & ActiveDocument.Bookmarks("User_Name").Range.Text & ActiveDocument.Bookmarks("Cell_Phone_Number").Range.Text
    strTo = "nanders8@good-sam.com"
      strAtt = ActiveDocument.FullName
    
    Set olkApp = CreateObject("outlook.application")
    With olkApp.createitem(0)
        .to = strTo
        .Subject = strSubject
        .body = strBody
        .attachments.Add strAtt
        '.send
        .Display
    End With
    Set olkApp = Nothing
End Sub
Any assistance would be greatly appreciated.
Reply With Quote