I have looked around the internet for the solution to the following problem and came across only a few similar threads, none of which have solved this issue for me.
- I am using Mail Merge via Macros in my documents to automatically take data from a CSV file (letter.csv) and then call other macros to do processing. This automation was working perfectly for me in previous versions of MS Word.
- In MS Word 2013 however, when the datasource .CSV file is opened via Mail Merge, I get a prompt from word to specify Field and Record delimiters. This not only breaks my automation, but no matter which delimiters I specify, the Mail Merge command always leads to an exception.
VB Code which causes the prompt and subsequent exception:
ActiveDocument.MailMerge.OpenDataSource Name:=ActiveDocument.Path & "\..\letter.csv", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:="", SQLStatement:="", SQLStatement1 _
:=""
- My data source is a simple .CSV file named 'letter.csv' with only 1 row and many fields in that row.
- I have tried saving the .CSV as .txt and replacing the same in my macro. Also tried to seperate each field in the data source with a semi colon ; and identify each field with "" eg. "field 1";"field 2"; None of it will cause word to take some kind of default delimiters and not give me this prompt.
Can someone suggest a workaround for this or maybe an alternative approach? My only restrictions are I can only use Visual Basic for my Macro code.
Thanks,
Shreeraj.