Discussion:
Mailmerging to CSV text file - how to prevent message prompting for delimeters
(too old to reply)
Simon Verona
2005-02-23 19:03:02 UTC
Permalink
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
Simon Verona
2005-02-23 22:51:04 UTC
Permalink
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
Post by Simon Verona
I'm doing a mailmerge (actually labels) controlling Word via automation
from a vb.net project....
This works, except for one annoyance..
Name,Address1,Address2,Address3,Address4,Address5
"Mr Smith","no 1 aroad","a town","a county","a country","a postcode" etc
etc
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
Loading...