Mailmerging to CSV text file - how to prevent message prompting for delimeters

S

Simon Verona

I'm doing a mailmerge (actually labels) controlling Word via automation
from a vb.net project....

This works, except for one annoyance..

The source file is a Comma Seperated data file with a layout similar to :

Name,Address1,Address2,Address3,Address4,Address5
"Mr Smith","no 1 aroad","a town","a county","a country","a postcode" etc
etc

I'm mailmerging with the following line of code:

Doc.MailMerge.OpenDataSource(name:=filename, _

ConfirmConversions:=False, ReadOnly:=True, LinkToSource:=True, _

AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _

WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _

Format:=Word.WdOpenFormat.wdOpenFormatText, Connection:="",
SQLStatement:="", SQLStatement1 _

:="", SubType:=Word.WdMergeSubType.wdMergeSubTypeOther)



This works, except that a pop up window appears prompting for field and end
of record delimeters. How can i force this to use a comma and "enter" to
open the datasource?



Many thanks in advance

Simon Verona
 
S

Simon Verona

In case anybody else comes across this and is searching for the answer to
this question, you need to put the following line in before trying to
"opendatasource" :-

SendKeys.Send("{,}{,}{ENTER}{TAB}{TAB}{ENTER}")

This effectively simulates pushing the relevant keys on the keyboard to
fill in the dialog box that pops up. I'm sure that this is slightly long
winded in terms of keypresses but seems to work - at least on Word 2002...
I've no reason to think it shouldn't work on Word 2000 or Word 2003 but I
don't have them around to test.



Regards

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top