Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge.execute failing...
I have an application that is doing a mailmerge via OLE automation.
Seems to be very standard. The general process is 1) create the data file. 2) open the document for mail merge. 3) attach data source 4) merge it However, it will fail every time when I have a data source file that appears to be too big (at least that is my guess at this time), and the data file is really not all that big. The document that is being merged has one field { INCLUDETEXT "{MERGEFIELD 1}" } Which is used to select what document will be inserted into the mail merge. (Each data file may contain multiple document templates that must be used). If I have 50 records in the data file, the process will fail every time. If I have 25, it will never fail. Other information that may be relevant. 1) I am working with Word 2003 2) There is an image in the documents that is being inserted (it is a static image, not linked) 3) Also when the failure occurs, it does not return an error to the OLE automation server. I do not know that the failure/crash has occured until I go to unlink the fields, and it fails with an RPC error. Any help at all would be appreciated. TIA, Lucas J. Bowser |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge.execute failing...
I haven't tested this, and can only make some guesses/rather obvious
suggestions, but a. using INCLUDETEXT for this kind of thing appears to have got more and more unreliable over the years (even though this approach is documented in an MS KB article) b. does the merge work if you do it manually with the 50 records? c. Does it make any difference what the data source is? d. Are you able to remove the images from the included documents - if so, does that make a difference (it wasn't clear whether or not you had actually tried that). c. does it take a long time to merge? Assuming the problem is either "it takes a long time" or "the output is large", all you can do is try to reduce the time/size or look for another approach. other than removing inherently large objects such as images, I only know of one real show-stopper in merge, and that's using formatted bullets in your source documents. One possible workaround is to merge a single record at a time, i.e. do 50 merges of 1 record each. However, the code I have for that would only work for a "letter" type merge which was going directly to a printer or to separate output files, not a "directory" or "catalog" type merge. Here's the (VBA) code, just in case: Sub ProduceOneDocPerSourceRec() Dim intSourceRecord Dim objMerge As Word.MailMerge Dim strOutputDocumentName As String Dim TerminateMerge As Boolean ' Need to set up this object as the ActiveDocument changes when the ' merge is performed. Besides, it's clearer. Set objMerge = ActiveDocument.MailMerge With objMerge ' If no data source has been defined, do it here using OpenDataSource. ' But if it is already defined in the document, you should not need to define it here. ' .OpenDataSource _ ' Name:="whatever" intSourceRecord = 1 TerminateMerge = False Do Until TerminateMerge ..DataSource.ActiveRecord = intSourceRecord ' if we have gone past the end (and possibly, if there are no records) ' then the Activerecord will not be what we have just tried to set it to If .DataSource.ActiveRecord intSourceRecord Then TerminateMerge = True ' the record exists Else ' if you are merging to output documents, you ' need to create the document names... ' while we are looking at the correct activerecord, ' create the document path name ' e.g. something like the following, but in this case ' each lastname must be unique (and must not contain ' characters that are not allowed in a file name) strOutputDocumentName = _ "c:\mymergeletters\_" & _ ..DataSource.Datafields("lastname").Value & _ " letter.doc" ..DataSource.FirstRecord = intSourceRecord ..DataSource.LastRecord = intSourceRecord ' Comment in/out the destination you need ..Destination = wdSendToNewDocument '.Destination = wdSendToPrinter 'please check the constant name ..Execute ' Deal with the output document, if any ' The Activedocument is always the output document ' Add any parameters you need to these calls ActiveDocument.SaveAs strOutputDocumentName ActiveDocument.Close intSourceRecord = intSourceRecord + 1 End If Loop End With End Sub Peter Jamieson wrote in message oups.com... I have an application that is doing a mailmerge via OLE automation. Seems to be very standard. The general process is 1) create the data file. 2) open the document for mail merge. 3) attach data source 4) merge it However, it will fail every time when I have a data source file that appears to be too big (at least that is my guess at this time), and the data file is really not all that big. The document that is being merged has one field { INCLUDETEXT "{MERGEFIELD 1}" } Which is used to select what document will be inserted into the mail merge. (Each data file may contain multiple document templates that must be used). If I have 50 records in the data file, the process will fail every time. If I have 25, it will never fail. Other information that may be relevant. 1) I am working with Word 2003 2) There is an image in the documents that is being inserted (it is a static image, not linked) 3) Also when the failure occurs, it does not return an error to the OLE automation server. I do not know that the failure/crash has occured until I go to unlink the fields, and it fails with an RPC error. Any help at all would be appreciated. TIA, Lucas J. Bowser |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Conditional use of merge fields suddenly failing | Mailmerge | |||
How do I fix Word 2003 failing to start EXCEL32.CNV? | Microsoft Word Help | |||
Word failing to save document changes | Microsoft Word Help | |||
My Word 2003 cut and paste function keeps failing | Microsoft Word Help | |||
Hyperlinks to network file locations failing. | New Users |