A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Bypassing Header Record Delimiters Dialog



 
 
Thread Tools Display Modes
  #1  
Old April 6th, 2010, 10:10 PM posted to microsoft.public.word.mailmerge.fields
Nick Olsen
external usenet poster
 
Posts: 3
Default Bypassing Header Record Delimiters Dialog

I have a C# application that performs an automated Word mail merge. The data
souce is just a tab delimited text file I create. If the mail merge document
has more than one merge field (and obviously the data source has more than
one data field) then the merge goes smoothly without any required action by
the user. On the other hand, if the document only has one merge field, then
before merging, Word pops up with the Header Record Delimiters dialog box
requiring me to specify the Field and the Record delimiter. The selected
values, none and enter respectively, are correct so the only thing I have to
do is click OK. I'm not sure how to go about getting rid of this window. Is
there any way to programatically specify the delimiters? Is there something
I can do to the data source file so that this won't show up?



Thanks

Nick

  #2  
Old April 9th, 2010, 02:29 AM posted to microsoft.public.word.mailmerge.fields
Nick Olsen
external usenet poster
 
Posts: 3
Default Bypassing Header Record Delimiters Dialog

No one has any information that might be helpful for this?

"Nick Olsen" wrote:

I have a C# application that performs an automated Word mail merge. The data
souce is just a tab delimited text file I create. If the mail merge document
has more than one merge field (and obviously the data source has more than
one data field) then the merge goes smoothly without any required action by
the user. On the other hand, if the document only has one merge field, then
before merging, Word pops up with the Header Record Delimiters dialog box
requiring me to specify the Field and the Record delimiter. The selected
values, none and enter respectively, are correct so the only thing I have to
do is click OK. I'm not sure how to go about getting rid of this window. Is
there any way to programatically specify the delimiters? Is there something
I can do to the data source file so that this won't show up?



Thanks

Nick

  #3  
Old April 9th, 2010, 10:06 AM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Bypassing Header Record Delimiters Dialog

No one has any information that might be helpful for this?

I needed to check some stuff (and still need to!). I don't think it
makes a whole lot of difference, but which version(s) of Word are you
working with?

On the other hand, if the document only has one merge field, then
before merging,


AFAIK this problem only arises when the data source only has one column
- i.e. it has nothing to do with the number of merge fields you place in
the document. That's what I experience here, but please say if your
experience is different.

The simplest solution is, I suppose, to ensure that your data source
always has more than one column, if you have control over that. If you
have control, you might also be able to use a slightly less simple file
format (e.g. you might be better off writing out a very basic HTML file
that uses a table structure to hold the data).

Although Word does store info. about the delimiters, at least in some
situations,
a. if it does in this case, it doesn't appear to use it anyway
b. there is no way to specify the delimiter characters in
OpenDataSource or using any other method or property in the Word object
model

There are two other possible approaches to a workaround, one of which
I've never attempted:
a. use Sendkeys (or a Win32 message) to OK the dialog. Since you're
automating Word, you might be able to do that from your C# program. But
you'd probably also have to know in advance whether you needed to do it
or not. Never tried it.
b. use a .odc file to connect to the data source. e.g. to connect to a
file called c:\\myfiles\\mysource.txt you could have a file called
mysource.odc that has the following content:

html

head
meta http-equiv=Content-Type content="text/x-ms-odc; charset=utf-8"
meta name=ProgId content=ODC.Table
meta name=SourceType content=OLEDB
meta name=Table content="mysource#txt"
xml id=docprops/xmlxml id=msodcodc:OfficeDataConnection
xmlnsdc="urn:schemas-microsoft-comfficedc"
xmlns="http://www.w3.org/TR/REC-html40"
odc:Connection odc:Type="OLEDB"
odc:ConnectionStringProvider=Microsoft.Jet.OLEDB .4.0;User
ID=Admin;Data Source=C:\myfiles;Mode=Share Deny None;Jet OLEDB:Engine
Type=96;/odc:ConnectionString
odc:CommandTypeTable/odc:CommandType
odc:CommandTextmysource#txt/odc:CommandText
/odc:Connection
/odc:OfficeDataConnection
/xml
/head
/body

/html

(NB, there's normally more in a .odc than that, but you shouldn't need
the rest of it)

When you connect manually using OLE DB, Word would also normally ask for
a field delimiter character (with OLE DB/Jet, the record delimiter has
to be CRLF or perhaps a variant such as CR). So you would have the same
problem. But when you connect via a .odc, Word doesn't seem to ask, and
of course it doesn't actually need to know because there are no field
delimiters. But
a. OLE DB/Jet only works for text files with up to 255 fields
b. there could be trouble if you have one of the common delimiters on
your data
c. etc.

For more info on this approach, I suggest you look at

http://groups.google.com/group/micro...9588c43fc31d70


Peter Jamieson

http://tips.pjmsn.me.uk

On 09/04/2010 02:29, Nick Olsen wrote:
No one has any information that might be helpful for this?

"Nick Olsen" wrote:

I have a C# application that performs an automated Word mail merge. The data
souce is just a tab delimited text file I create. If the mail merge document
has more than one merge field (and obviously the data source has more than
one data field) then the merge goes smoothly without any required action by
the user. On the other hand, if the document only has one merge field, then
before merging, Word pops up with the Header Record Delimiters dialog box
requiring me to specify the Field and the Record delimiter. The selected
values, none and enter respectively, are correct so the only thing I have to
do is click OK. I'm not sure how to go about getting rid of this window. Is
there any way to programatically specify the delimiters? Is there something
I can do to the data source file so that this won't show up?



Thanks

Nick

  #4  
Old April 21st, 2010, 06:28 PM posted to microsoft.public.word.mailmerge.fields
Nick Olsen
external usenet poster
 
Posts: 3
Default Bypassing Header Record Delimiters Dialog

I appologize for not getting back you. I was waiting for an email notifying
me of replies but it never came!

You are correct, I did mean that it shows up when there is only one column
in the data file not just one merge field.

I will try the odc route. I did read something about that elsewhere but was
hoping to find an easier solution like some flag you have to set.

Thanks for the information!.

Nick

"Peter Jamieson" wrote:

No one has any information that might be helpful for this?


I needed to check some stuff (and still need to!). I don't think it
makes a whole lot of difference, but which version(s) of Word are you
working with?

On the other hand, if the document only has one merge field, then
before merging,


AFAIK this problem only arises when the data source only has one column
- i.e. it has nothing to do with the number of merge fields you place in
the document. That's what I experience here, but please say if your
experience is different.

The simplest solution is, I suppose, to ensure that your data source
always has more than one column, if you have control over that. If you
have control, you might also be able to use a slightly less simple file
format (e.g. you might be better off writing out a very basic HTML file
that uses a table structure to hold the data).

Although Word does store info. about the delimiters, at least in some
situations,
a. if it does in this case, it doesn't appear to use it anyway
b. there is no way to specify the delimiter characters in
OpenDataSource or using any other method or property in the Word object
model

There are two other possible approaches to a workaround, one of which
I've never attempted:
a. use Sendkeys (or a Win32 message) to OK the dialog. Since you're
automating Word, you might be able to do that from your C# program. But
you'd probably also have to know in advance whether you needed to do it
or not. Never tried it.
b. use a .odc file to connect to the data source. e.g. to connect to a
file called c:\\myfiles\\mysource.txt you could have a file called
mysource.odc that has the following content:

html

head
meta http-equiv=Content-Type content="text/x-ms-odc; charset=utf-8"
meta name=ProgId content=ODC.Table
meta name=SourceType content=OLEDB
meta name=Table content="mysource#txt"
xml id=docprops/xmlxml id=msodcodc:OfficeDataConnection
xmlnsdc="urn:schemas-microsoft-comfficedc"
xmlns="http://www.w3.org/TR/REC-html40"
odc:Connection odc:Type="OLEDB"
odc:ConnectionStringProvider=Microsoft.Jet.OLEDB .4.0;User
ID=Admin;Data Source=C:\myfiles;Mode=Share Deny None;Jet OLEDB:Engine
Type=96;/odc:ConnectionString
odc:CommandTypeTable/odc:CommandType
odc:CommandTextmysource#txt/odc:CommandText
/odc:Connection
/odc:OfficeDataConnection
/xml
/head
/body

/html

(NB, there's normally more in a .odc than that, but you shouldn't need
the rest of it)

When you connect manually using OLE DB, Word would also normally ask for
a field delimiter character (with OLE DB/Jet, the record delimiter has
to be CRLF or perhaps a variant such as CR). So you would have the same
problem. But when you connect via a .odc, Word doesn't seem to ask, and
of course it doesn't actually need to know because there are no field
delimiters. But
a. OLE DB/Jet only works for text files with up to 255 fields
b. there could be trouble if you have one of the common delimiters on
your data
c. etc.

For more info on this approach, I suggest you look at

http://groups.google.com/group/micro...9588c43fc31d70


Peter Jamieson

http://tips.pjmsn.me.uk

On 09/04/2010 02:29, Nick Olsen wrote:
No one has any information that might be helpful for this?

"Nick Olsen" wrote:

I have a C# application that performs an automated Word mail merge. The data
souce is just a tab delimited text file I create. If the mail merge document
has more than one merge field (and obviously the data source has more than
one data field) then the merge goes smoothly without any required action by
the user. On the other hand, if the document only has one merge field, then
before merging, Word pops up with the Header Record Delimiters dialog box
requiring me to specify the Field and the Record delimiter. The selected
values, none and enter respectively, are correct so the only thing I have to
do is click OK. I'm not sure how to go about getting rid of this window. Is
there any way to programatically specify the delimiters? Is there something
I can do to the data source file so that this won't show up?



Thanks

Nick

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.