![]() |
excel vba word merge printer error
I have an Excel vba macro that does a Word mail merge. If the
resulting document gets over a few pages in size, the printer prints some of the pages, then throws out an error page that is pretty meaningless dump of junk and stops printing. (I am guess it is from some sort of over run of data in the buffer ?). If I modify the vba code to send the resulting document to a new Word document, then print that document from Word, it prints just fine. Any idea why this happens? Does this method of printing do something different than printing right from Word ? Here is the code: Dim oWord As Word.Application Dim oMainDoc As Word.Document Dim oOutputDoc As Word.Document Dim omm As Word.MailMerge Set oWord = CreateObject("Word.Application") Set oDoc = oWord.Documents.Open("p:\carbboom online system\onlineorders.doc") Set omm = oDoc.MailMerge With omm .DataSource.FirstRecord = wddefaultfirstrecord .DataSource.LastRecord = wdDefaultLastRecord .Destination = wdSendToPrinter .Execute Pause:=False End With Set oOutputDoc = Nothing Set omm = Nothing oDoc.Close Set oDoc = Nothing oWord.Quit Set oWord = Nothing |
excel vba word merge printer error
You'd probably have more luck in a Word NG, but...
Does this code work properly if run from Word ? Do you get any help if you change the Pause to True ? What if .Destination=wdSendToNewDocument ? NickHK wrote in message ups.com... I have an Excel vba macro that does a Word mail merge. If the resulting document gets over a few pages in size, the printer prints some of the pages, then throws out an error page that is pretty meaningless dump of junk and stops printing. (I am guess it is from some sort of over run of data in the buffer ?). If I modify the vba code to send the resulting document to a new Word document, then print that document from Word, it prints just fine. Any idea why this happens? Does this method of printing do something different than printing right from Word ? Here is the code: Dim oWord As Word.Application Dim oMainDoc As Word.Document Dim oOutputDoc As Word.Document Dim omm As Word.MailMerge Set oWord = CreateObject("Word.Application") Set oDoc = oWord.Documents.Open("p:\carbboom online system\onlineorders.doc") Set omm = oDoc.MailMerge With omm .DataSource.FirstRecord = wddefaultfirstrecord .DataSource.LastRecord = wdDefaultLastRecord .Destination = wdSendToPrinter .Execute Pause:=False End With Set oOutputDoc = Nothing Set omm = Nothing oDoc.Close Set oDoc = Nothing oWord.Quit Set oWord = Nothing |
excel vba word merge printer error
This same thing happens when I try to print Excel documents using VBA
macros, so it is not a Word specifc issue. When a document gets to a certain size, it seems to cause this error. But this only happens is VBA is doing the printing- if I have the maco send the output to a file, then print that file directly from Excel or Word, it prints fine. NickHK wrote: You'd probably have more luck in a Word NG, but... Does this code work properly if run from Word ? Do you get any help if you change the Pause to True ? What if .Destination=wdSendToNewDocument ? NickHK wrote in message ups.com... I have an Excel vba macro that does a Word mail merge. If the resulting document gets over a few pages in size, the printer prints some of the pages, then throws out an error page that is pretty meaningless dump of junk and stops printing. (I am guess it is from some sort of over run of data in the buffer ?). If I modify the vba code to send the resulting document to a new Word document, then print that document from Word, it prints just fine. Any idea why this happens? Does this method of printing do something different than printing right from Word ? Here is the code: Dim oWord As Word.Application Dim oMainDoc As Word.Document Dim oOutputDoc As Word.Document Dim omm As Word.MailMerge Set oWord = CreateObject("Word.Application") Set oDoc = oWord.Documents.Open("p:\carbboom online system\onlineorders.doc") Set omm = oDoc.MailMerge With omm .DataSource.FirstRecord = wddefaultfirstrecord .DataSource.LastRecord = wdDefaultLastRecord .Destination = wdSendToPrinter .Execute Pause:=False End With Set oOutputDoc = Nothing Set omm = Nothing oDoc.Close Set oDoc = Nothing oWord.Quit Set oWord = Nothing |
All times are GMT +1. The time now is 07:26 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com