.PrintOut with Background:=True on HP 5Si garbles intermittently Times Roman chracters

Posted on 2006-06-27
Last Modified: 2012-08-14

I have a VB.NET application that calls Word to Open, Print, and Close files.  I use the following code to print out the files:

objWord.ActiveDocument.PrintOut(Background:=True, Range:=Word.WdPrintOutRange.wdPrintAllDocument, Item:=Word.WdPrintOutItem.wdPrintDocumentContent, Collate:=True, PageType:=Word.WdPrintOutPages.wdPrintAllPages, Copies:=CShort(txtNumCopies.Text))

The porblem is that when "Background:=True" some of the print outs get their Times Roman sections garbled (characters all printed at start of a line or are just missing).

Using "Background:=False" solves the problem, but this greatly increases the time to print a document which is unacceptable.

Note that I have also tried the following that does not help (in between Prinout call and Close call):

            Do While objWord.Application.BackgroundPrintingStatus > 0

And I have tried settign the printer options to "Dowload Fonts", "Raster", and all optimizations turned "off".

So anyone have any suggestions?
Question by:rmundkowsky
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 15

Expert Comment

ID: 16999647
Check your printer drivers - I have had similar problems with HP printers that were using the PCL6 drivers - when they were changed back to PCL5e drivers, the problems went away

Author Comment

ID: 17003553
Nope.  Just installed the PCL5e driver and tried it.  Same problem.
LVL 20

Expert Comment

ID: 17004697
I assume that the document prints okay if you don't open it via code (e.g. open the document in Word and print it)?  Also, is it just one document or is it any document?  Also, what version of Word are we working with?

If it still doesn't print right in normal Word operation, I'd recommend the steps outlined in this article (a couple of which you've already tried):
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.


Author Comment

ID: 17006851

Yes, the document/s print fine in Word, either if you Open and Print them or Select and Print via Explorer.

Using Word 2003.  I am not at the Office so I can not tell you the Service Pack right now.

The problem is only intermittent.  So if I print 10 documents using my code then 5 (randomally selected) documents will have the problem.  Also note that this problem occurs where every the application is deployed.  I am not sure if it occurs only with 5 Si (and MX), but I do know that these have had the problem.

On a side note, I was think about the font that does not have the problem, I believe it make be a bitmapped version of Arial

I'll see if any of the suggestions from your link pan-out.
LVL 20

Expert Comment

ID: 17009008
That's going to be a tough one to figure out.  But you probably already knew that :)  Intermittent Word problems are the worst, especially when they occur everywhere, to everyone in random situations.  You said that they print fine in a non-code session, but are they printed enough to know for sure?

I know this will sound like a cop-out, but I really think the printer driver has something to do with this.  Is there any other printer that you can use to test it out?

Author Comment

ID: 17011922
No, not a cope out.  But I am pretty sure it is not the printer driver at this point, because:

1) The error does not occur using my code if "Background:=False"
2) Print multiple documents via Select/Print via Explorer does not cause the error. (FYI, the error occurs at least one in a batch of 20 prints and Explorer allow ~70 per batch)
3) I have tried to print with all kinds of different printer settings: font not being substitued, with being substitued, as True Types as bnitmaps, download soft fonts, via the Postscript driver, via the PCL driver, GL & raster, lower resolution (300 dpi)

And today, I noted that the Arial fonts that are fine in printouts are also True Type.

So It seems to be a bug in VBA, MS Word or .NET.  

I am thinking my next try at a solution is to port the application from Net 1.1 to 2.0.


Author Comment

ID: 17014498
Well, found an interesting fact.  If I open the Word file and save it in a different folder then the problem still occurs, but if I open it and save it with a different name then the problem is fixed.  So I am convinced that the document is corrupted some how.  I think I start looking into how it was created.
LVL 20

Expert Comment

ID: 17014849
Is there anything weird in the path and/or filename?

Author Comment

ID: 17015647
Nope.  My guess is Word does some formatting, parsing, or something when it thinks it is saving a file with changes.

Author Comment

ID: 17021258
Ok, found a fix.

Based on this:

I found that removing the Word temporary files in between printing files fixes the problem.  So code like this in the print loop makes it work:

                        Dim _Files As String()
                        Dim f As String
                        _Files = Directory.GetFiles(System.IO.Path.GetTempPath())
                        For Each f In _Files
                            Catch ex As Exception
                            End Try

LVL 20

Expert Comment

ID: 17025493
I'm glad you got it working!

Author Comment

ID: 17205485
Well, I found that my fix did not totally corrct the problem.  I am still working the issue.

Accepted Solution

DarthMod earned 0 total points
ID: 17232209
PAQed with points refunded (500)

Community Support Moderator

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question