As Microsoft says « We does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when run in this environment. »
If you really want to use
Install Office PIA
First, you need Office (2000, XP or 2003) and install the PIA of your version :
Office XP PIAs
Office 2003 Update : Redistributable Primary Interop Assemblies
Usualy you can find it, on the Office Installation CD during custom installation (in .Net Programmability Support of each Office application).
Installing PIA, will add some assemblies of your GAC (Global Assembly Cache), it will avoid useless Primary Interop generation when you create your project.
Right-click on your project
Choose Add Reference
Select COM tab (not .NET
Add Microsoft [Word/Excel/Access] NN Object Library
As ASPNET user is not an interactive User, it hasn’t user profile (so no desktop, no "my documents", no user folders...)
During Office Automation, Office try to initialize some user data and it try to save them in the "Documents and Settings" user folder. Too bad ! So Office create user folders (Application Data, My Documents...) in C :\.
To avoid this, you have to :
create a REAL user account (ie OfficeForASPNET)
setup the web site to impersonate this account
grant DCOM Local Execution and Local Activation rights
In order to instanciate Word/Excel/Access... classes using PIA (Primary Interop Assemblies), the OfficeForASPNET user has to be authorized.
In dcomcnfg.exe (or Control Panel\Administration Tools\Components Services) :
go to : Components Services\Computers\My Computer\DCOM Configuration\Microsoft [Word/Excel/Access...] Application
In Allow Activation and Execution, add OfficeForASPNET user and grant Local Execution and Local Activation rights
Now, you can use any Office document in your web application.