Solved

Why won't this print?

Posted on 2011-09-16
4
366 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 69

Expert Comment

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

Author Comment

by:bgernon
Comment Utility
It worked.  
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
Comment Utility
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
Comment Utility
I tried this just seconds before your response. It worked. Thanks.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now