Free Support Forum - aspose.com

Trouble with date switches on mail merge fields

I am using Aspose.Word 2009-09-17 01:58:20,version:1.3.49.0 with .Net 1.1

The merge field looks like this: MERGEFIELD LFS1_CALDATECAL\@"MMMM dd, yyyy"

I am performing the mail merge by passing an array of field names and a string array of field values so the date is being passed in as a string.

No errors are thrown during the merge. The date is jut not being formatted.

Performing this merge with Word 2003 seems to work.

I am wondering if the date needs to be a date object instead of string?

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Could you please provide me sample data that you use? I will check the issue and provide you more information.

Best regards,

Absolutely, I copied this straight out of the watch window. It shows the contents of the name and value arrays.

fieldNames {Length=2} String()
(0) "LFS0_CALDATECAL" String
(1) "LFS0_CALHRADDRESSLINE1" String


fieldValues {Length=2} String()
(0) "10/29/2009" String
(1) "10/29/2009" String

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> Hi

Thank you for additional information. To apply date formatting switches, date should be first converted to DateTime type. But your string cannot be converted to DateTime directly. As a workaround you can try using the following code:

Document doc = new Document(@"Test001\in.doc");

CultureInfo provider = CultureInfo.InvariantCulture;

DateTime date = DateTime.ParseExact("10/29/2009", "d", provider);

doc.MailMerge.Execute(new string[] { "LFS1_CALDATECAL" }, new object[] { date });

doc.Save(@"Test001\out.doc");

Hope this helps.

Best regards,

I am not having much luck with the workaround. I cannot get the formatting applied to the date. The project I am working with is written in VB .NET 1.1 which should not matter but you never know.

I am posting my test program, if you see any reason why it is not working let me know. Thanks

Sub <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Main()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Dim license As License = New License

license.SetLicense("Aspose.Words.lic")

Dim doc As Document = New Document("24A1E3CB0BS028.TRF")

Dim fieldNames(1) As String

Dim fieldValues(1) As Object

Dim d As DateTime = DateTime.ParseExact("10/29/2009", "d", CultureInfo.InvariantCulture)

fieldNames(0) = "LFS0_CALDATECAL"

fieldNames(1) = "LFS0_CALHRADDRESSLINE1"

fieldValues(0) = d

fieldValues(1) = "Address"

doc.MailMerge.Execute(fieldNames, fieldValues)

Console.WriteLine("Result:")

Console.WriteLine(doc.ToTxt().Trim())

Console.WriteLine(vbCrLf & "d.ToString(): " & d.ToString())

Console.Read()

End Sub

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.

Best regards,

Are you guys any closer to getting date switches working?

Hi

Thanks for your request. Unfortunately, the issue is still unresolved. You will be notified as soon as it is fixed.

Best regards,

The issues you have found earlier (filed as 11419) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.