error text for common errors missing (HRESULT only)

B

bcarsto

has anyone out there programmer with publisher 2007 see this problem before?

Publisher 2007 does not return any informative error text for common errors
such as file not found (Open method) and invalid printer (doc.ActivePrinter).


For example for file not found, Publisher 2003 returns: “Publisher cannot
locate the file…†while 2007 returns "Exception from HRESULT: 0x80FF0032".
Similary thin for ActivePrinter.

Here is sample code

Microsoft.Office.Interop.Publisher._Application pub = new
Microsoft.Office.Interop.Publisher.ApplicationClass();
Microsoft.Office.Interop.Publisher.Document doc;

try
{

doc = pub.Open(@"C:\filenotfound.pub", true, false,

Microsoft.Office.Interop.Publisher.PbSaveOptions.pbDoNotSaveChanges);

}
catch (Exception ex)
{
// Message = "Exception from HRESULT: 0x80FF0032"
MessageBox.Show(ex.Message);
}


doc =
pub.NewDocument(Microsoft.Office.Interop.Publisher.PbWizard.pbWizardNone, 0);

doc.Pages[1].Shapes.AddTextbox(Microsoft.Office.Interop.Publisher.PbTextOrientation.pbTextOrientationHorizontal, 10, 10, 500, 300);
try
{
doc.ActivePrinter = "printer does not exist";
}
catch (System.Runtime.InteropServices.COMException cex)
{
// MESSAGE = Error HRESULT E_FAIL has been returned from a
call to a COM component.
MessageBox.Show(cex.Message);
}

catch (Exception ex)
{
// message = "Error HRESULT E_FAIL has been returned from a
call to a COM component."}
MessageBox.Show(ex.Message);
}
doc.Close();

Regards,
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top