Thread: [Solved] Word Macro driving me crazy
View Single Post
 
Old 06-21-2018, 11:06 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
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 ofgmayor has much to be proud of
Default

Unfortunately what you see is what happens with ambiguous dates. The code assumes US format by default. There does not seem to be an easy answer (apart from e.g. using http://www.gmayor.com/ManyToOne.htm to create the PDF and the e-mail).

As the date is correct in the merge document, presumably through the use of a formatting switch on the merge field, have you considered reading the value from the merge document, while it is available, and write it to a string. You can then write the string to your e-mail body (and that will retain the format as it is in the document).
Code:
Dim strDate As String
Dim oFld As Field
    Set oDoc = ActiveDocument
    With oDoc
        .MailMerge.ViewMailMergeFieldCodes = False
        For Each oFld In .Fields
            If InStr(1, oFld.code, "MeldeschlussJVA") > 0 Then
                strDate = oFld.Result
                Exit For
            End If
        Next oFld
    End With
__________________
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