View Single Post
 
Old 11-10-2016, 02:36 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Perhaps the following, though together with your other macro it should give you enough information to modify it to your needs.

Code:
Option Explicit

Sub Macro1()
Const strpath As String = "C:\Path\"
Const BAAR As String = "BAAR"
Const MARCA As String = "marca"
Dim strName As String
Dim strMessage As String
Dim fso As Object
Dim oDoc As Document

    strMessage = "Raport de verif pt. dosar " & BAAR & vbCr & _
                 "In atentia d-lui " & strName & "," & vbCr & _
                 "Urmare a verificarii dosarului " & BAAR & " auto pagubit marca " & MARCA & _
                 "va transmitem atasat raportul de verificare." & vbCr & _
                 "Rog confirmati primirea." & vbCr & _
                 "Cu stima," & vbCr & vbCr & _
                 "Mihai STAICU"

    Set fso = CreateObject("Scripting.FileSystemObject")
    Select Case True
        Case fso.FileExists(strpath & "Mail AU.docx")
            Set oDoc = Documents.Add(Template:=strpath & "Mail AU.docx")
            strName = "Adrian Uta"
            oDoc.Range.Text = strMessage
            oDoc.SaveAs2 FileName:=strpath & "AU.docx", addtorecentfiles:=False

        Case fso.FileExists(strpath & "Mail EN.docx")
            Set oDoc = Documents.Add(Template:=strpath & "Mail EN.docx")
            strName = "Emilia Negoita"
            oDoc.Range.Text = strMessage
            oDoc.SaveAs2 FileName:=strpath & "EN.docx", addtorecentfiles:=False
    End Select
lbl_Exit:
    Set fso = Nothing
    Set oDoc = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote