Solved

Why won't this print?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

23 Experts available now in Live!

Get 1:1 Help Now