Please help.... {printing worksheet in Excel}

rahavtom
10-02-2004, 10:16 AM
Hello!

I'm using VB.NET and office XP. When I try to print a worksheet I get the following error:
"Exception from HRESULT : 0x800A03EC"

The code I use is:

Dim excelApp As New Excel.Application
Dim excelBook As Excel.Workbook = excelApp.Workbooks.Open("C:\ClinicTech\Files\1.xls")
Dim excelWorksheet As Excel.Worksheet = CType(excelBook.Worksheets(1), Excel.Worksheet)
'Makes Excel invisible to the user until spreadsheet is populated
excelApp.Visible = False
With excelWorksheet
'Populate Excel spreadsheet
Try
.Range("E7").Value = iBPD

Catch ex As Exception
MsgBox(ex.Message)
End Try

'Make Excel visible
excelApp.Visible = True
excelApp.Sheets.Select("Graph")
excelApp.Sheets.PrintOut()

End WithThanks!
Tom.

herilane
10-02-2004, 10:26 AM
You probably want something like this instead:excelBook.Sheets("Graph").PrintOut()There is no need to select a sheet before printing it.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum