![]() |
|
#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 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to save Word file by field name as filename using VBA button?
|
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 |
How can I save a Word Document as a PDF file with a merged field filename?
|
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 |
Auto update Filename field
|
Oliver Beirne | Word VBA | 4 | 10-19-2012 03:33 AM |