Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

How to verify that a document printed in VB.NET using Word apis?

Avatar of EnvisageInformationSystems
EnvisageInformationSystems asked on
.NET ProgrammingMicrosoft Word
2 Comments1 Solution517 ViewsLast Modified:
I have a VB.net application that reads a series of records and creates a word document from them in large batches daily. THe program loads a word template from SQL Server, grabs the shapes and replaces the text within it, and then calls PrintOut().  What we are finding is that after 8 months of daily use, all of a sudden, some of the documents are not coming out on the printer end. All the history and 'trace' records in our database show that the document was processed, and I even went so far as to add a second PrintOUt() function that prints to file directly after the PrintOUt() to the printer has happened, and that file is there, so I am at a loss. Everyone feels that the problem is with the printer, but what my client would like to do is have me generate a report that would inform someone that certain documents didn't print.

I have spent some time trying to determine if there is a way to determine if a document successfully printed, but I am having trouble finding anything. Can anyone help?

Here is a snippet of the print code I am using...

If chkPrintPageStart <> 0 And chkPrintPageEnd <> 0 Then
                 
   aDoc.PrintOut(Range:=Microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintFromTo,  _
                     From:=CStr(chkPrintPageStart), To:=CStr(chkPrintPageEnd), PrintToFile:=False)
               

Else
   aDoc.PrintOut(PrintToFile:=False)                
End If
           
If (debugPrinter) Then
  aDoc.PrintOut(PrintToFile:=True, OutputFileName:="C:\\DebugPrinter\\" &  _
            CStr(aCheck.CheckNumber) & ".doc")
End If

IN all cases, the line aDoc.PrintOut(PrintToFile:=False)  is the one executed in this context, as for this application we are always printing the entire document. I would think PrintOUt() would throw an exception if there was a problem, but I don't recieve anything in the catch that surrounds all this code. WE have checked the eventlog and all as well and no problems surface there. It just appears that the print request is lost in the ether.....

Thanks in advance for your help!!

Tim
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel OzFlag of Australia imageSenior Software Engineer
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers