excel vba word merge printer error

M

mcarey101

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
 
N

NickHK

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
 
M

mcarey101

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top