Tips, Tricks, and Fixes for when your computer doesn't do what it's told.

Monday, March 24, 2008

COM objects and ASP

Creating a spreadsheet from an ASP page requires referencing Excel as a COM object on the hosting IIS server. To format the page of the spreadsheet, Excel has to have printers installed, but this can be a problem when called from ASP.

The workaround is to setup printers for the SYSTEM account (which is the account that ASP runs under).

  1. Ensure that the user you are currently logged into on the server has the desired printers installed.
  2. Launch the Registry Editor (Regedit.exe).
  3. Select the following key: HKEY_CURRENT_USER
    \Software\Microsoft\Windows NT\Current Version\Devices
  4. From the Registry menu, click Export Registry File.
  5. In the File Name text box, type c:\Devices.reg.
  6. Select the following key: HKEY_CURRENT_USER
    \Software\Microsoft\Windows NT\Current Version\PrinterPorts
  7. From the Registry menu, click Export Registry File.
  8. In the File Name text box, type c:\PrinterPorts.reg.
  9. Select the following key: HKEY_CURRENT_USER
    \Software\Microsoft\Windows NT\Current Version\Windows
  10. From the Registry menu, click Export Registry File.
  11. In the File Name text box, type c:\Windows.reg.
  12. From the Start button, select Run. Open Devices.reg in Notepad by typing Notepad Devices.reg in Run dialog box.
  13. Replace the text HKEY_CURRENT_USER with HKEY_USERS\.DEFAULT
  14. Save the file. Then import it into the registry by double-clicking the file in Windows Explorer.
  15. Repeat steps 13 through 15 for PrinterPorts.reg and Windows.reg

http://support.microsoft.com/kb/184291

No comments: