Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Simon Verona - 23 Feb 2005 19:03 GMT
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 - 23 Feb 2005 22:51 GMT
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

> I'm doing a mailmerge (actually labels)  controlling Word via automation
> from a vb.net project....
[quoted text clipped - 29 lines]
>
> Simon Verona

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.