Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem when Printing Excel Document

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
US
Hey Folks,

I have an ASP page which opens an Excel document on the server, puts data into it, prints it out and then closed it without saving.

I have developed this on my own machine (IIS5 on WinXP) and it works fine when I run it locally or from a remote machine.

So I copied it onto my webserver (IIS6 in Windows Server 2003) and tried to run it. By debugging it I have found the problem is something to do with the printing. When I comment out the print line, the program will return. But it just hangs if I try to print it.

The code to print out the document is simply:

Code:
xlApp.ActiveSheet.PrintOut , , 1, false, Request.Form("Printer")

It just prints the document to the printer selected by the user.

The only main difference is that I have Excel 2003 on my machine and the server only has Excel 2000. Would that have anything to do with it or is it likely to be some other problem?

Mighty
 
Have you tried using that line within Excel to see what happens? I can see where a different (particularly an earlier) version of Excel could cause problems. I would start by trying to test it on the earlier version or determining what the correct syntax may be for the earlier version.

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Is it possible that the login account used by ASP does not have permissions to do the printing?
 
Sheco - that is a possibility - how do I check that?

Mighty
 
You could test the theory by using the IIS Admin tool to either turn off anonymous access or set anonymous to use a real domain account instead of the limited local IUSR_MachineName account ... just don't forget to put it back if this doesn't fix it.
 
Tried changing it to use the domain admin account but no joy - still won't print.

Mighty
 
Changed it to my account and now getting the following error message:

Microsoft Excel error '800a03ec'

No printers are installed. To install a printer, point to Settings on the Windows Start menu, click Printers, and then double-click Add Printer. Follow the instructions in the wizard.

/printLHR.asp, line 397

This error message is being generated by the line in the code where the file is printed. I have 6 printers installed on this server so I don't know why this error message is being generated.

Mighty
 
Mighty said:
I have 6 printers installed on this server so I don't know why this error message is being generated.
You have six printers installed on this printer? But are they installed under your ID (presuming that it is under your ID that you are receiving this error message?

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Tried to get IIS to use the domain admin account first and nothing was happening. Switched it to use my account and that is when I was at least getting the error message. So I set up all the printers under my account on the webserver but am still getting the same error message. However, once I had set up the printers I logged back into the server as administrator. Maybe I should try staying logged in on the server as myself.

Will try that and see if I have any joy.

Mighty
 
To print from com object, some data has to be read from the registry. System account may not have the registry entries set up a priori. This article shows how to do it for printer both local to the server as well as the network printer which needs network service account.
 
Tried that with no joy. I tried using just the network printers section as I am trying to print to a network printer. I made the registry modification as per the microsoft link you suggested but I got an Excel error saying that no printers were installed. So then I made all the changes suggested for the local printer too to be sure and now it's just hanging and not doing anything.

To rule out permissions issues, I am logged in to the webserver using the administrator account and I have set up IIS to use the domain administrator account.

Any more suggestions - very frustrating as this works fine on my development machine (IIS5 on WinXP). The problem is only occurring on my webserver (IIS6 on Win Srv 2003)

Mighty
 
I just can't understand how it can be a permissions issue. When I run the ASP page in the browser, IIS opens up Excel in the background. Because IIS runs using the administrator account, I can see in the Task Manager that Excel.exe is running using the administrator account. I have added all the required printers under the administrator account and administrator surely has permission to print.

I'm lost!!!

Mighty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top