List Info

Thread: =?iso-8859-1?q?Microsoft.Office.Interop.Excel=AD.WorkSheet.PrintOut_Method_(COM_Error_HRESULT:0x8004




=?iso-8859-1?q?Microsoft.Office.Interop. Excel=AD.WorkSheet.PrintOut_Method_(COM_ Error_HRESULT:0x8004
user name
2006-02-02 08:51:07
Hello,


I´m trying to print an Excel worksheet with C#. I can load
the
worksheet
and save it to disk fine, but, when I try to print that
worksheet,
using WorkSheet.PrintOut Method,
it always gives me a COM Exception telling me that the
operation
finished with  HRESULT:0x800401A8. Here is the
code:


this.printDialog.PrinterSettings = new
System.Drawing.Printing.PrinterSettings();
			DialogResult result = this.printDialog.ShowDialog();

if (result == DialogResult.OK)
{
   m_WorkSheet.PrintOut(Type.Missing, Type.Missing, 1,
false,
this.printDialog.PrinterSettings.PrinterName,false, false,
Type.Missing);
}

What I´m doing wrong?

Also, I have tried the msdn example, (The only difference is
that the
example prints the document to a file, instead of sending it
to the
printer). with the same result.

Thanks in advance.

=?iso-8859-1?q?Re:_Microsoft.Office.Inte rop.Excel=AD.WorkSheet.PrintOut_Method_( COM_Error_HRESULT:0x
user name
2006-02-06 15:03:26
It works now.

Instead of using Type.Missing, with the PrintOute method,
you have to
use System.Reflection.Missing.Value. Using that you will
avoid the
error:

m_WorkSheet.PrintOut(System.Reflection.Missing.Value,
System.Reflection.Missing.Value, 1, false,
this.printDialog.PrinterSettings.PrinterName,false, false,
System.Reflection.Missing.Value);

Microsoft´s documentation is clearly wrong with this.

Bye 

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )