Solved

Why won't this print?

Posted on 2011-09-16
4
369 Views
Last Modified: 2012-05-12
When the print button is clicked, a document is created, then it should print. I can see the document spooling in the printer queue, then printing.  I get the message 'This document has been sent to the printer', but nothing comes out of the printer.

I've been using this as a guide:

http://www.java2s.com/Tutorial/VB/0440__Windows/CreateWorddocumentandprint.htm

Should I be using another method?



Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
Dim wdApp As New Word.Application
Dim wdDoc As New Word.Document

wdDoc = wdApp.Documents.Add
wdDoc.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekMainDocument
With wdDoc
   .Range.InsertAfter("Employer Information")
   .Range.Font.Name = "Arial"
   .Range.Font.Size = 14
   .Range.InsertParagraphAfter()
   .Range.InsertAfter("Employer: " & AcctNum.Text.ToString)
   .Range.Font.Name = "Arial"
   .Range.Font.Size = 12
   .Paragraphs.Item(1).Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter    
   .Paragraphs.Item(2).Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
   .Range.InsertAfter("Business Name: " & txtEmployerName.Text)
End With
Try
  wdDoc.PrintOut(True, True)
Catch ex As Exception
    Dim msg As String = String.Format("An error occured: {0}", ex.Message)
    MessageBox.Show(msg)
End Try
wdApp.Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
wdApp.Quit()
wdApp = Nothing
End Sub

Open in new window

0
Comment
Question by:bgernon
  • 2
4 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 36550164
try setting the BackGround argument (of the Printout method) to False
0
 

Author Comment

by:bgernon
ID: 36550269
It worked.  
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36550278
wdDoc.PrintOut(True, True)

The second True. It tells Word to append to a file, so the printout is not sent to the printer. Try wdDoc.PrintOut(True)
0
 

Author Closing Comment

by:bgernon
ID: 36550308
I tried this just seconds before your response. It worked. Thanks.
0

Featured Post

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.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 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