Home |
Search |
Today's Posts |
#1
|
|||
|
|||
MailMerge.CreateHeaderSource
I am having problems getting this functionality to work!
I have Word 2003, and am trying to give the users a list of fields to select while creating their letter templates. Using the following statement gives me a message box that the headerstring is 255 characters, which it is. Dim headerString as String Dim fileName as String headerString = "LastName, FirstName, Address1, Address2, City, State, Zip, Country, ........" '(Len(headerString) 255 chars) fileName = "HeaderFields.doc" objWord.MailMerge.CreateHeaderSource fileName, , , headerString I think this limitation is due to the fact that it stores the fields in a single row table in the Word Document specified by fileName. Cannot have unlimited number of cells on one row. I tried getting around this by manually creating an excel spreadsheet with the fields in different cells, and calling objWord.MailMerge.OpenHeaderSource fileName.xls This time it failed on an RPC call. Has anybody faced this problem before? |
#2
|
|||
|
|||
I think this limitation is due to the fact that it stores the fields in a
single row table in the Word Document specified by fileName. Cannot have unlimited number of cells on one row. Correct. objWord.MailMerge.OpenHeaderSource fileName.xls As far as I know, when Word opens a header source, it must be in a format that Word can get at using a converter (internal or external). That means that not every type of data source can be used as a header source. In the case of Excel sheets, they might be useable if you have the Excel converter and can specify the correct Format parameter, However, I think I would try a different route which is to create a Word document, or plain text file, with comma-delimited column names. You can then exceed the 63/64 column limit of a Word table. If you also duplicate the header row you are much less likely to see the "field and record delimiters" dialog. E.g. field1,field2,field3 field1,field2,field3 If you need to create such a file on the fly you can use Word automation to create a Word file or plain old VBA file handling verbs (OPEN FOR OUTPUT etc.) for plain text files. It's probably better to stick to Word if the column names have non-Latin characters but I'd try it and see. Peter Jamieson "Meena Bhashyam" Meena wrote in message ... I am having problems getting this functionality to work! I have Word 2003, and am trying to give the users a list of fields to select while creating their letter templates. Using the following statement gives me a message box that the headerstring is 255 characters, which it is. Dim headerString as String Dim fileName as String headerString = "LastName, FirstName, Address1, Address2, City, State, Zip, Country, ........" '(Len(headerString) 255 chars) fileName = "HeaderFields.doc" objWord.MailMerge.CreateHeaderSource fileName, , , headerString I think this limitation is due to the fact that it stores the fields in a single row table in the Word Document specified by fileName. Cannot have unlimited number of cells on one row. I tried getting around this by manually creating an excel spreadsheet with the fields in different cells, and calling objWord.MailMerge.OpenHeaderSource fileName.xls This time it failed on an RPC call. Has anybody faced this problem before? |
#3
|
|||
|
|||
I think you resolved my problem. I was trying not to use the text file
because it kept giving me the delimiter dialog box which I was trying to get around. Repeating the header lines worked! Thank you so much for your help. Meena "Peter Jamieson" wrote: I think this limitation is due to the fact that it stores the fields in a single row table in the Word Document specified by fileName. Cannot have unlimited number of cells on one row. Correct. objWord.MailMerge.OpenHeaderSource fileName.xls As far as I know, when Word opens a header source, it must be in a format that Word can get at using a converter (internal or external). That means that not every type of data source can be used as a header source. In the case of Excel sheets, they might be useable if you have the Excel converter and can specify the correct Format parameter, However, I think I would try a different route which is to create a Word document, or plain text file, with comma-delimited column names. You can then exceed the 63/64 column limit of a Word table. If you also duplicate the header row you are much less likely to see the "field and record delimiters" dialog. E.g. field1,field2,field3 field1,field2,field3 If you need to create such a file on the fly you can use Word automation to create a Word file or plain old VBA file handling verbs (OPEN FOR OUTPUT etc.) for plain text files. It's probably better to stick to Word if the column names have non-Latin characters but I'd try it and see. Peter Jamieson "Meena Bhashyam" Meena wrote in message ... I am having problems getting this functionality to work! I have Word 2003, and am trying to give the users a list of fields to select while creating their letter templates. Using the following statement gives me a message box that the headerstring is 255 characters, which it is. Dim headerString as String Dim fileName as String headerString = "LastName, FirstName, Address1, Address2, City, State, Zip, Country, ........" '(Len(headerString) 255 chars) fileName = "HeaderFields.doc" objWord.MailMerge.CreateHeaderSource fileName, , , headerString I think this limitation is due to the fact that it stores the fields in a single row table in the Word Document specified by fileName. Cannot have unlimited number of cells on one row. I tried getting around this by manually creating an excel spreadsheet with the fields in different cells, and calling objWord.MailMerge.OpenHeaderSource fileName.xls This time it failed on an RPC call. Has anybody faced this problem before? |