Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
"too many data fields " error
When I run my mail merge for a single record, I get no errors. When I run
the mail merge with more than one record, I get a "Record contained too many data fields" error. Others' help with this question suggested "usually caused by a mismatch between the number of fields listed in the header record of the data source and the number of fields Word finds in the data records." I have tried to compare these two, but evidently they're REALLY different, unless I'm misinterprinting the following: MsgBox ActiveDocument.MailMerge.Fields.Count = 60 MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 My delimiter is "|", and I don't believe it's anywhere it shouldn't be. As I've said, individual records work great, but multiple records give me this error, and generate only one document. Any suggestions as to how to solve this problem? TIA |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
"too many data fields " error
MsgBox ActiveDocument.MailMerge.Fields.Count = 60
MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 The first of these is related to the number of Word fields in the document (well, certain types of fields, anyway) - e.g. if you just have one { MERGEFIELD } field, the count should be 1. The second is the number of columns in the data source, and as far as I know, that means the number of columns in the header, not in the current record. So these two numbers describe completely different things. However, that doesn't really help, so: a. how many columns do you expect Word to find in the data source? Is it 60, 277, or something else? b. If you execute the following VBA code and look at the results in the VBE Immediate window, does that give you any clues about what is happening? Sub showds() Dim objDataField As MailMergeDataField For Each objDataField In ActiveDocument.MailMerge.DataSource.DataFields Debug.Print objDataField.Name, objDataField.Value Next End Sub Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... When I run my mail merge for a single record, I get no errors. When I run the mail merge with more than one record, I get a "Record contained too many data fields" error. Others' help with this question suggested "usually caused by a mismatch between the number of fields listed in the header record of the data source and the number of fields Word finds in the data records." I have tried to compare these two, but evidently they're REALLY different, unless I'm misinterprinting the following: MsgBox ActiveDocument.MailMerge.Fields.Count = 60 MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 My delimiter is "|", and I don't believe it's anywhere it shouldn't be. As I've said, individual records work great, but multiple records give me this error, and generate only one document. Any suggestions as to how to solve this problem? TIA |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
"too many data fields " error
Thanks, Peter for the help and suggestions.
Well, the only thing that looks unusual from running your sub is an AutoMerge field, which I can't find in the doc. Anyway, since the first page works great, I just cut everything but the first page out of the dataSource, and then copied the first page a second time. Should have generated 2 documents. Got the same error message, and only one document generated. Any other hope? st. "Peter Jamieson" wrote in message ... .... However, that doesn't really help, so: a. how many columns do you expect Word to find in the data source? Is it 60, 277, or something else? b. If you execute the following VBA code and look at the results in the VBE Immediate window, does that give you any clues about what is happening? Sub showds() Dim objDataField As MailMergeDataField For Each objDataField In ActiveDocument.MailMerge.DataSource.DataFields Debug.Print objDataField.Name, objDataField.Value Next End Sub Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... When I run my mail merge for a single record, I get no errors. When I run the mail merge with more than one record, I get a "Record contained too many data fields" error. Others' help with this question suggested "usually caused by a mismatch between the number of fields listed in the header record of the data source and the number of fields Word finds in the data records." I have tried to compare these two, but evidently they're REALLY different, unless I'm misinterprinting the following: MsgBox ActiveDocument.MailMerge.Fields.Count = 60 MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 My delimiter is "|", and I don't believe it's anywhere it shouldn't be. As I've said, individual records work great, but multiple records give me this error, and generate only one document. Any suggestions as to how to solve this problem? TIA |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
"too many data fields " error
Hi st,
I'm running out of steam a bit here, so can probaby only reply properly 2morrow, but can you bie a bit more specific about the format and content of the data source? What do you mean by the "First page" etc.? I had the impression from your earlier message that you were using a delimited text file as the data source, but now it sounds more like a Word document or Excel file. "Automerge" fields generally indicate that Word could not find a heading for a column that contains data, e.g. if you have an Excel sheet with colum heading in row 1 for columns 1 to 9, but data in column 10 with no heading in that column, you might get an Automerge field - if you're using an Excel file, make sure there is a heading for each column that has not been "cleared" in the excel sheet. best I can do for now, Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter for the help and suggestions. Well, the only thing that looks unusual from running your sub is an AutoMerge field, which I can't find in the doc. Anyway, since the first page works great, I just cut everything but the first page out of the dataSource, and then copied the first page a second time. Should have generated 2 documents. Got the same error message, and only one document generated. Any other hope? st. "Peter Jamieson" wrote in message ... ... However, that doesn't really help, so: a. how many columns do you expect Word to find in the data source? Is it 60, 277, or something else? b. If you execute the following VBA code and look at the results in the VBE Immediate window, does that give you any clues about what is happening? Sub showds() Dim objDataField As MailMergeDataField For Each objDataField In ActiveDocument.MailMerge.DataSource.DataFields Debug.Print objDataField.Name, objDataField.Value Next End Sub Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... When I run my mail merge for a single record, I get no errors. When I run the mail merge with more than one record, I get a "Record contained too many data fields" error. Others' help with this question suggested "usually caused by a mismatch between the number of fields listed in the header record of the data source and the number of fields Word finds in the data records." I have tried to compare these two, but evidently they're REALLY different, unless I'm misinterprinting the following: MsgBox ActiveDocument.MailMerge.Fields.Count = 60 MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 My delimiter is "|", and I don't believe it's anywhere it shouldn't be. As I've said, individual records work great, but multiple records give me this error, and generate only one document. Any suggestions as to how to solve this problem? TIA |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
"too many data fields " error
Thanks, Peter, for your help.
Yes, I am using a delimited text file as the datasource. Excel is not involved. As I said, the mail merge works great on individual records, but once I put two records in the datasource, I get the error. By "first page", I meant the document containing the data for the first record. (With this error, subsequent documents are never generated.) The only thing "unusual" is that I have opened the datasource file before the merge and replaced any " character in the datasource file with `, and then saved the file. st. "Peter Jamieson" wrote in message ... Hi st, I'm running out of steam a bit here, so can probaby only reply properly 2morrow, but can you bie a bit more specific about the format and content of the data source? What do you mean by the "First page" etc.? I had the impression from your earlier message that you were using a delimited text file as the data source, but now it sounds more like a Word document or Excel file. "Automerge" fields generally indicate that Word could not find a heading for a column that contains data, e.g. if you have an Excel sheet with colum heading in row 1 for columns 1 to 9, but data in column 10 with no heading in that column, you might get an Automerge field - if you're using an Excel file, make sure there is a heading for each column that has not been "cleared" in the excel sheet. best I can do for now, Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter for the help and suggestions. Well, the only thing that looks unusual from running your sub is an AutoMerge field, which I can't find in the doc. Anyway, since the first page works great, I just cut everything but the first page out of the dataSource, and then copied the first page a second time. Should have generated 2 documents. Got the same error message, and only one document generated. Any other hope? st. "Peter Jamieson" wrote in message ... ... However, that doesn't really help, so: a. how many columns do you expect Word to find in the data source? Is it 60, 277, or something else? b. If you execute the following VBA code and look at the results in the VBE Immediate window, does that give you any clues about what is happening? Sub showds() Dim objDataField As MailMergeDataField For Each objDataField In ActiveDocument.MailMerge.DataSource.DataFields Debug.Print objDataField.Name, objDataField.Value Next End Sub Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... When I run my mail merge for a single record, I get no errors. When I run the mail merge with more than one record, I get a "Record contained too many data fields" error. Others' help with this question suggested "usually caused by a mismatch between the number of fields listed in the header record of the data source and the number of fields Word finds in the data records." I have tried to compare these two, but evidently they're REALLY different, unless I'm misinterprinting the following: MsgBox ActiveDocument.MailMerge.Fields.Count = 60 MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 My delimiter is "|", and I don't believe it's anywhere it shouldn't be. As I've said, individual records work great, but multiple records give me this error, and generate only one document. Any suggestions as to how to solve this problem? TIA |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
"too many data fields " error
Unfortunately, if Word doesn't recognise the record/field structure
properly, there's not a lot you can do. There are Windows functions that guess the encoding of a file and they work using a number of rules which may not always give the right answer. You could try the suggestion I posted elsewhere If the data source is not confidential, I'd be happy to have a look at it here and see if I can spot anything. Otherwise, what to do depends on whether the data has to be in this format in the first place, and if not, what the best alternative is - if for example there are no more than 63 columns you could consider using Word, but there are other possibilities. One other thing may be worth trying: if you check Word Tools|Options|general|Confirm conversion at open then just try to open your deleimited file in Word, what type of file does it think it is? Does Word think it is an encoded text file, and if so, what does it think the encoding is? Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter, for your help. Yes, I am using a delimited text file as the datasource. Excel is not involved. As I said, the mail merge works great on individual records, but once I put two records in the datasource, I get the error. By "first page", I meant the document containing the data for the first record. (With this error, subsequent documents are never generated.) The only thing "unusual" is that I have opened the datasource file before the merge and replaced any " character in the datasource file with `, and then saved the file. st. "Peter Jamieson" wrote in message ... Hi st, I'm running out of steam a bit here, so can probaby only reply properly 2morrow, but can you bie a bit more specific about the format and content of the data source? What do you mean by the "First page" etc.? I had the impression from your earlier message that you were using a delimited text file as the data source, but now it sounds more like a Word document or Excel file. "Automerge" fields generally indicate that Word could not find a heading for a column that contains data, e.g. if you have an Excel sheet with colum heading in row 1 for columns 1 to 9, but data in column 10 with no heading in that column, you might get an Automerge field - if you're using an Excel file, make sure there is a heading for each column that has not been "cleared" in the excel sheet. best I can do for now, Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter for the help and suggestions. Well, the only thing that looks unusual from running your sub is an AutoMerge field, which I can't find in the doc. Anyway, since the first page works great, I just cut everything but the first page out of the dataSource, and then copied the first page a second time. Should have generated 2 documents. Got the same error message, and only one document generated. Any other hope? st. "Peter Jamieson" wrote in message ... ... However, that doesn't really help, so: a. how many columns do you expect Word to find in the data source? Is it 60, 277, or something else? b. If you execute the following VBA code and look at the results in the VBE Immediate window, does that give you any clues about what is happening? Sub showds() Dim objDataField As MailMergeDataField For Each objDataField In ActiveDocument.MailMerge.DataSource.DataFields Debug.Print objDataField.Name, objDataField.Value Next End Sub Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... When I run my mail merge for a single record, I get no errors. When I run the mail merge with more than one record, I get a "Record contained too many data fields" error. Others' help with this question suggested "usually caused by a mismatch between the number of fields listed in the header record of the data source and the number of fields Word finds in the data records." I have tried to compare these two, but evidently they're REALLY different, unless I'm misinterprinting the following: MsgBox ActiveDocument.MailMerge.Fields.Count = 60 MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 My delimiter is "|", and I don't believe it's anywhere it shouldn't be. As I've said, individual records work great, but multiple records give me this error, and generate only one document. Any suggestions as to how to solve this problem? TIA |
#7
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
"too many data fields " error
Hej, Peter, thanks for all your help. I believe if I replace the "~"
throughout the file, I can get it to work, but I don't know how to replace a "~" with a CarrierReturn. Here's what I try, and I don't get a CR, but a box. Sub test() Dim fso As Object, theFile As Object, theText As String Set fso = CreateObject("Scripting.FileSystemObject") Set theFile = fso.opentextfile("c:\datasource1.dat", 1) theText = theFile.readall theFile.Close theText = Replace(theText, "~", vbLf) Set theFile = fso.opentextfile("c:\crth6005.dat", 2) theFile.write (theText) theFile.Close End Sub If you can tell me how to replace the ~ with a CR, I'll try that before bothering you with the datasource. I've tried it manually, and it seems to do the trick. TIA. st. "Peter Jamieson" wrote in message ... Unfortunately, if Word doesn't recognise the record/field structure properly, there's not a lot you can do. There are Windows functions that guess the encoding of a file and they work using a number of rules which may not always give the right answer. You could try the suggestion I posted elsewhere If the data source is not confidential, I'd be happy to have a look at it here and see if I can spot anything. Otherwise, what to do depends on whether the data has to be in this format in the first place, and if not, what the best alternative is - if for example there are no more than 63 columns you could consider using Word, but there are other possibilities. One other thing may be worth trying: if you check Word Tools|Options|general|Confirm conversion at open then just try to open your deleimited file in Word, what type of file does it think it is? Does Word think it is an encoded text file, and if so, what does it think the encoding is? Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter, for your help. Yes, I am using a delimited text file as the datasource. Excel is not involved. As I said, the mail merge works great on individual records, but once I put two records in the datasource, I get the error. By "first page", I meant the document containing the data for the first record. (With this error, subsequent documents are never generated.) The only thing "unusual" is that I have opened the datasource file before the merge and replaced any " character in the datasource file with `, and then saved the file. st. "Peter Jamieson" wrote in message ... Hi st, I'm running out of steam a bit here, so can probaby only reply properly 2morrow, but can you bie a bit more specific about the format and content of the data source? What do you mean by the "First page" etc.? I had the impression from your earlier message that you were using a delimited text file as the data source, but now it sounds more like a Word document or Excel file. "Automerge" fields generally indicate that Word could not find a heading for a column that contains data, e.g. if you have an Excel sheet with colum heading in row 1 for columns 1 to 9, but data in column 10 with no heading in that column, you might get an Automerge field - if you're using an Excel file, make sure there is a heading for each column that has not been "cleared" in the excel sheet. best I can do for now, Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter for the help and suggestions. Well, the only thing that looks unusual from running your sub is an AutoMerge field, which I can't find in the doc. Anyway, since the first page works great, I just cut everything but the first page out of the dataSource, and then copied the first page a second time. Should have generated 2 documents. Got the same error message, and only one document generated. Any other hope? st. "Peter Jamieson" wrote in message ... ... However, that doesn't really help, so: a. how many columns do you expect Word to find in the data source? Is it 60, 277, or something else? b. If you execute the following VBA code and look at the results in the VBE Immediate window, does that give you any clues about what is happening? Sub showds() Dim objDataField As MailMergeDataField For Each objDataField In ActiveDocument.MailMerge.DataSource.DataFields Debug.Print objDataField.Name, objDataField.Value Next End Sub Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... When I run my mail merge for a single record, I get no errors. When I run the mail merge with more than one record, I get a "Record contained too many data fields" error. Others' help with this question suggested "usually caused by a mismatch between the number of fields listed in the header record of the data source and the number of fields Word finds in the data records." I have tried to compare these two, but evidently they're REALLY different, unless I'm misinterprinting the following: MsgBox ActiveDocument.MailMerge.Fields.Count = 60 MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 My delimiter is "|", and I don't believe it's anywhere it shouldn't be. As I've said, individual records work great, but multiple records give me this error, and generate only one document. Any suggestions as to how to solve this problem? TIA |
#8
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
"too many data fields " error
Light dawns, a bit...
I would try vbCrLf instead of vbLf. Certainly if Word is opening a delimited file using ODBC, it must have a CrLf type record separator - the same may be true of OLEDB files. Peter Jamieson "zSplash" wrote in message ... Hej, Peter, thanks for all your help. I believe if I replace the "~" throughout the file, I can get it to work, but I don't know how to replace a "~" with a CarrierReturn. Here's what I try, and I don't get a CR, but a box. Sub test() Dim fso As Object, theFile As Object, theText As String Set fso = CreateObject("Scripting.FileSystemObject") Set theFile = fso.opentextfile("c:\datasource1.dat", 1) theText = theFile.readall theFile.Close theText = Replace(theText, "~", vbLf) Set theFile = fso.opentextfile("c:\crth6005.dat", 2) theFile.write (theText) theFile.Close End Sub If you can tell me how to replace the ~ with a CR, I'll try that before bothering you with the datasource. I've tried it manually, and it seems to do the trick. TIA. st. "Peter Jamieson" wrote in message ... Unfortunately, if Word doesn't recognise the record/field structure properly, there's not a lot you can do. There are Windows functions that guess the encoding of a file and they work using a number of rules which may not always give the right answer. You could try the suggestion I posted elsewhere If the data source is not confidential, I'd be happy to have a look at it here and see if I can spot anything. Otherwise, what to do depends on whether the data has to be in this format in the first place, and if not, what the best alternative is - if for example there are no more than 63 columns you could consider using Word, but there are other possibilities. One other thing may be worth trying: if you check Word Tools|Options|general|Confirm conversion at open then just try to open your deleimited file in Word, what type of file does it think it is? Does Word think it is an encoded text file, and if so, what does it think the encoding is? Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter, for your help. Yes, I am using a delimited text file as the datasource. Excel is not involved. As I said, the mail merge works great on individual records, but once I put two records in the datasource, I get the error. By "first page", I meant the document containing the data for the first record. (With this error, subsequent documents are never generated.) The only thing "unusual" is that I have opened the datasource file before the merge and replaced any " character in the datasource file with `, and then saved the file. st. "Peter Jamieson" wrote in message ... Hi st, I'm running out of steam a bit here, so can probaby only reply properly 2morrow, but can you bie a bit more specific about the format and content of the data source? What do you mean by the "First page" etc.? I had the impression from your earlier message that you were using a delimited text file as the data source, but now it sounds more like a Word document or Excel file. "Automerge" fields generally indicate that Word could not find a heading for a column that contains data, e.g. if you have an Excel sheet with colum heading in row 1 for columns 1 to 9, but data in column 10 with no heading in that column, you might get an Automerge field - if you're using an Excel file, make sure there is a heading for each column that has not been "cleared" in the excel sheet. best I can do for now, Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter for the help and suggestions. Well, the only thing that looks unusual from running your sub is an AutoMerge field, which I can't find in the doc. Anyway, since the first page works great, I just cut everything but the first page out of the dataSource, and then copied the first page a second time. Should have generated 2 documents. Got the same error message, and only one document generated. Any other hope? st. "Peter Jamieson" wrote in message ... ... However, that doesn't really help, so: a. how many columns do you expect Word to find in the data source? Is it 60, 277, or something else? b. If you execute the following VBA code and look at the results in the VBE Immediate window, does that give you any clues about what is happening? Sub showds() Dim objDataField As MailMergeDataField For Each objDataField In ActiveDocument.MailMerge.DataSource.DataFields Debug.Print objDataField.Name, objDataField.Value Next End Sub Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... When I run my mail merge for a single record, I get no errors. When I run the mail merge with more than one record, I get a "Record contained too many data fields" error. Others' help with this question suggested "usually caused by a mismatch between the number of fields listed in the header record of the data source and the number of fields Word finds in the data records." I have tried to compare these two, but evidently they're REALLY different, unless I'm misinterprinting the following: MsgBox ActiveDocument.MailMerge.Fields.Count = 60 MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 My delimiter is "|", and I don't believe it's anywhere it shouldn't be. As I've said, individual records work great, but multiple records give me this error, and generate only one document. Any suggestions as to how to solve this problem? TIA |
#9
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
"too many data fields " error
Thanks SO MUCH for your help, Peter. Your suggestions solved my problem
completely! So simple, yet so elusive... You're the best! st. "Peter Jamieson" wrote in message ... Light dawns, a bit... I would try vbCrLf instead of vbLf. Certainly if Word is opening a delimited file using ODBC, it must have a CrLf type record separator - the same may be true of OLEDB files. Peter Jamieson "zSplash" wrote in message ... Hej, Peter, thanks for all your help. I believe if I replace the "~" throughout the file, I can get it to work, but I don't know how to replace a "~" with a CarrierReturn. Here's what I try, and I don't get a CR, but a box. Sub test() Dim fso As Object, theFile As Object, theText As String Set fso = CreateObject("Scripting.FileSystemObject") Set theFile = fso.opentextfile("c:\datasource1.dat", 1) theText = theFile.readall theFile.Close theText = Replace(theText, "~", vbLf) Set theFile = fso.opentextfile("c:\crth6005.dat", 2) theFile.write (theText) theFile.Close End Sub If you can tell me how to replace the ~ with a CR, I'll try that before bothering you with the datasource. I've tried it manually, and it seems to do the trick. TIA. st. "Peter Jamieson" wrote in message ... Unfortunately, if Word doesn't recognise the record/field structure properly, there's not a lot you can do. There are Windows functions that guess the encoding of a file and they work using a number of rules which may not always give the right answer. You could try the suggestion I posted elsewhere If the data source is not confidential, I'd be happy to have a look at it here and see if I can spot anything. Otherwise, what to do depends on whether the data has to be in this format in the first place, and if not, what the best alternative is - if for example there are no more than 63 columns you could consider using Word, but there are other possibilities. One other thing may be worth trying: if you check Word Tools|Options|general|Confirm conversion at open then just try to open your deleimited file in Word, what type of file does it think it is? Does Word think it is an encoded text file, and if so, what does it think the encoding is? Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter, for your help. Yes, I am using a delimited text file as the datasource. Excel is not involved. As I said, the mail merge works great on individual records, but once I put two records in the datasource, I get the error. By "first page", I meant the document containing the data for the first record. (With this error, subsequent documents are never generated.) The only thing "unusual" is that I have opened the datasource file before the merge and replaced any " character in the datasource file with `, and then saved the file. st. "Peter Jamieson" wrote in message ... Hi st, I'm running out of steam a bit here, so can probaby only reply properly 2morrow, but can you bie a bit more specific about the format and content of the data source? What do you mean by the "First page" etc.? I had the impression from your earlier message that you were using a delimited text file as the data source, but now it sounds more like a Word document or Excel file. "Automerge" fields generally indicate that Word could not find a heading for a column that contains data, e.g. if you have an Excel sheet with colum heading in row 1 for columns 1 to 9, but data in column 10 with no heading in that column, you might get an Automerge field - if you're using an Excel file, make sure there is a heading for each column that has not been "cleared" in the excel sheet. best I can do for now, Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter for the help and suggestions. Well, the only thing that looks unusual from running your sub is an AutoMerge field, which I can't find in the doc. Anyway, since the first page works great, I just cut everything but the first page out of the dataSource, and then copied the first page a second time. Should have generated 2 documents. Got the same error message, and only one document generated. Any other hope? st. "Peter Jamieson" wrote in message ... ... However, that doesn't really help, so: a. how many columns do you expect Word to find in the data source? Is it 60, 277, or something else? b. If you execute the following VBA code and look at the results in the VBE Immediate window, does that give you any clues about what is happening? Sub showds() Dim objDataField As MailMergeDataField For Each objDataField In ActiveDocument.MailMerge.DataSource.DataFields Debug.Print objDataField.Name, objDataField.Value Next End Sub Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... When I run my mail merge for a single record, I get no errors. When I run the mail merge with more than one record, I get a "Record contained too many data fields" error. Others' help with this question suggested "usually caused by a mismatch between the number of fields listed in the header record of the data source and the number of fields Word finds in the data records." I have tried to compare these two, but evidently they're REALLY different, unless I'm misinterprinting the following: MsgBox ActiveDocument.MailMerge.Fields.Count = 60 MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 My delimiter is "|", and I don't believe it's anywhere it shouldn't be. As I've said, individual records work great, but multiple records give me this error, and generate only one document. Any suggestions as to how to solve this problem? TIA |
#10
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
"too many data fields " error
Actually I should have asked you that very question much earlier as it had
occurred to me, but when you mentioned you were using | as a field delimiter I'd made the assumption that you'd have mentioned it if your record deleimiter was also unusual. Maybe you did mention it. Assumptions always catch you out - I should know better really as I've been doing this for long enough :-) Anyway, glad it all works now! Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks SO MUCH for your help, Peter. Your suggestions solved my problem completely! So simple, yet so elusive... You're the best! st. "Peter Jamieson" wrote in message ... Light dawns, a bit... I would try vbCrLf instead of vbLf. Certainly if Word is opening a delimited file using ODBC, it must have a CrLf type record separator - the same may be true of OLEDB files. Peter Jamieson "zSplash" wrote in message ... Hej, Peter, thanks for all your help. I believe if I replace the "~" throughout the file, I can get it to work, but I don't know how to replace a "~" with a CarrierReturn. Here's what I try, and I don't get a CR, but a box. Sub test() Dim fso As Object, theFile As Object, theText As String Set fso = CreateObject("Scripting.FileSystemObject") Set theFile = fso.opentextfile("c:\datasource1.dat", 1) theText = theFile.readall theFile.Close theText = Replace(theText, "~", vbLf) Set theFile = fso.opentextfile("c:\crth6005.dat", 2) theFile.write (theText) theFile.Close End Sub If you can tell me how to replace the ~ with a CR, I'll try that before bothering you with the datasource. I've tried it manually, and it seems to do the trick. TIA. st. "Peter Jamieson" wrote in message ... Unfortunately, if Word doesn't recognise the record/field structure properly, there's not a lot you can do. There are Windows functions that guess the encoding of a file and they work using a number of rules which may not always give the right answer. You could try the suggestion I posted elsewhere If the data source is not confidential, I'd be happy to have a look at it here and see if I can spot anything. Otherwise, what to do depends on whether the data has to be in this format in the first place, and if not, what the best alternative is - if for example there are no more than 63 columns you could consider using Word, but there are other possibilities. One other thing may be worth trying: if you check Word Tools|Options|general|Confirm conversion at open then just try to open your deleimited file in Word, what type of file does it think it is? Does Word think it is an encoded text file, and if so, what does it think the encoding is? Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter, for your help. Yes, I am using a delimited text file as the datasource. Excel is not involved. As I said, the mail merge works great on individual records, but once I put two records in the datasource, I get the error. By "first page", I meant the document containing the data for the first record. (With this error, subsequent documents are never generated.) The only thing "unusual" is that I have opened the datasource file before the merge and replaced any " character in the datasource file with `, and then saved the file. st. "Peter Jamieson" wrote in message ... Hi st, I'm running out of steam a bit here, so can probaby only reply properly 2morrow, but can you bie a bit more specific about the format and content of the data source? What do you mean by the "First page" etc.? I had the impression from your earlier message that you were using a delimited text file as the data source, but now it sounds more like a Word document or Excel file. "Automerge" fields generally indicate that Word could not find a heading for a column that contains data, e.g. if you have an Excel sheet with colum heading in row 1 for columns 1 to 9, but data in column 10 with no heading in that column, you might get an Automerge field - if you're using an Excel file, make sure there is a heading for each column that has not been "cleared" in the excel sheet. best I can do for now, Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... Thanks, Peter for the help and suggestions. Well, the only thing that looks unusual from running your sub is an AutoMerge field, which I can't find in the doc. Anyway, since the first page works great, I just cut everything but the first page out of the dataSource, and then copied the first page a second time. Should have generated 2 documents. Got the same error message, and only one document generated. Any other hope? st. "Peter Jamieson" wrote in message ... ... However, that doesn't really help, so: a. how many columns do you expect Word to find in the data source? Is it 60, 277, or something else? b. If you execute the following VBA code and look at the results in the VBE Immediate window, does that give you any clues about what is happening? Sub showds() Dim objDataField As MailMergeDataField For Each objDataField In ActiveDocument.MailMerge.DataSource.DataFields Debug.Print objDataField.Name, objDataField.Value Next End Sub Peter Jamieson "zSplash" zNOSPAMSplash@ gci.net wrote in message ... When I run my mail merge for a single record, I get no errors. When I run the mail merge with more than one record, I get a "Record contained too many data fields" error. Others' help with this question suggested "usually caused by a mismatch between the number of fields listed in the header record of the data source and the number of fields Word finds in the data records." I have tried to compare these two, but evidently they're REALLY different, unless I'm misinterprinting the following: MsgBox ActiveDocument.MailMerge.Fields.Count = 60 MsgBox ActiveDocument.MailMerge.DataSource.DataFields.Cou nt = 277 My delimiter is "|", and I don't believe it's anywhere it shouldn't be. As I've said, individual records work great, but multiple records give me this error, and generate only one document. Any suggestions as to how to solve this problem? TIA |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word2003 data fields vs Word97 | Mailmerge | |||
Fields inside footer -- Last record showing field instead of data | Mailmerge | |||
Fields only display the code not the data!! | Microsoft Word Help | |||
Help! I'm getting error messages too much-can't open Resume Wizard | Microsoft Word Help | |||
Data Execution Prevention Error | Microsoft Word Help |