![]() |
|
#1
|
|||
|
|||
![]()
I have created a very simple Word form to be used as evaluations within my department. After the evaluator fills in the various check boxes, dates, etc, I have a simple submit button that sends the completed evaluation as an attachment to the Chief of the department. The very first field on the form is the "clinician being reviewed", a fill in text box. I would like for the subject line of the email AND the file name of the document to be that person's name, then the type of evaluation (I have 3 different evals, depending on what is being done). Example: If I am evaluating Charles Xavier, the file name would be Charles Xavier.doc, and the email subject would be Charles Xavier, Treatment Plan. My code is listed below:
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.SaveAs2 FileName:=("M:\File Name.doc") With EmailItem .Subject = "Treatment" .Body = "" & vbCrLf & _ "" & vbCrLf & _ "" .To = "Chief's email" .Cc = "" .Importance = 2 .Attachments.Add Doc.FullName .Send Doc.Close End With Application.ScreenUpdating = True Set Doc = Nothing Set OL = Nothing Set EmailItem = Nothing End Sub |
#2
|
||||
|
||||
![]()
What sort of 'text field'? What is the name of the text field?
Can you post the form?
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
I'll try to put it up tonight; my work network won't allow me to upload.
Last edited by TribeBuckeyeFan; 02-01-2017 at 11:32 AM. |
#4
|
|||
|
|||
![]()
OK, there we go. Had to send it to myself, then upload from my phone.
|
#5
|
||||
|
||||
![]()
See the attached, which includes a couple of extra functions from my web site. Change the e-mail address(es) and the body text as required.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
chemtoli | Word VBA | 5 | 01-25-2017 08:06 AM |
How to save Excel file by field name as filename | chemtoli | Excel | 4 | 01-22-2017 08:32 AM |
![]() |
kp2009 | Word VBA | 5 | 08-27-2015 11:45 PM |
Save Filename based on Text Field | madcar86 | Word VBA | 8 | 10-19-2014 12:53 AM |
![]() |
Oliver Beirne | Word VBA | 4 | 10-19-2012 03:33 AM |