Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Why won't this print?

Posted on 2011-09-16
4
Medium Priority
?
375 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 1500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

916 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