Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Knowing if MS Word has printed OK ?

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I'm working on a demo application that prints a selected MS Word document to a printer.
I need to establish whether this was successful or not.

The code is as follows :

private void button1_Click(object sender, System.EventArgs e)
{
try
{
System.Diagnostics.Process p = new Process();
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = @"C:\TEST3.doc";
p.StartInfo.UseShellExecute = true;
p.StartInfo.Verb = "print";
p.StartInfo.CreateNoWindow = true;
p.Start();
p.WaitForExit();
int i = p.ExitCode;
p.Dispose();
if (i == 0)
{
MessageBox.Show("Printed OK");
}
else
{
MessageBox.Show("DID NOT PRINT OK");
}
}
catch (Exception ex)
{
MessageBox.Show("Unable to print report" + "\n\n" + ex.ToString());
}
}

This works OK apart from when I unhook from the network and my report fails to be printed (no printer to print to).
It still returns an ExitCode of 0 (for successful).

How can I understand as to whether or not the report has actually been sent to the printer and not returned an error (i.e. it's not there) ?

Any help would be appreciated.
Thanks in advance
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top