Printing from ASP .NET page

  • Thread starter Thread starter Nancy Kafer
  • Start date Start date
N

Nancy Kafer

I have a simple test application (one execute button) that opens an Excel
spreadsheet and then attempts to print the worksheet to a network printer.
When the application attempts to print the worksheet I receive the message:

"No printers are installed. To install a printer, point to Settings..."

Since this application is running on my machine I made sure my machine had a
default printer defined. But this still didn't fix the problem. Has anyone
else seen this problem? I am attaching my code below:

Dim objApp As Excel.Application
Dim objBook As Excel._Workbook
Dim objBooks As Excel.Workbooks
Dim objSheets As Excel.Sheets
Dim objSheet As Excel._Worksheet
Dim range As Excel.Range

objApp = New Excel.Application
'objApp.ActivePrinter = ps.PrinterName
objBooks = objApp.Workbooks
objBook = objBooks.Open("C:\Inetpub\wwwroot\report0.xls")
objSheets = objBook.Worksheets

'objApp.Worksheets.PrintOut()
objSheets.PrintOut()

objBooks.Close()

Thanks for any help.
 
The APIs used by Excel to print depend on registry entries located in
HKEY_CURRENT_USER. Depending on which user context the process is
running under, different information will be loaded into this hive.
ASP.NET pages run with the ASPNET account by default - you've setup
printers for your account.

There are some tricky workarounds (i.e.
http://support.microsoft.com/kb/288367/EN-US/), but are you sure you
want to print from the server side?
 
Back
Top