System.UnauthorizedAccessException: Retrieving the COM class factory for Word Interop fails with error 80070005
Here is my fix for this problem:
I'm using Win 7 64bit and Office 2007
Run program "dcomcnfg -32". ( You cant find the word and excel components if it runs under 64bit)
Go to "Console Root/Component Services/Computer/My Computer/DCOM Config/"
Look up Microsoft Word and Excel and choose properties.
Go to Security and select "Customize" under "Configuration Permissions. (If needed you might want to change the other permissions as well, but I didn't need to)
Add "IIS_IUSRS" and give it "Full Control".
Now go to "Identity" and select "The interactive user".
Do not forget to press "OK" when done. :D
I Hope this helps you with your problem and also the rest who gets here and read this.
Retrieving the COM class factory for component error while generating word document
It definitely sounds like a permissions problem. Are you running your code in a windows service? The service normally runs as Local System, which may not have permission to access the Word object model. Additionally, if word is already running using the credentials of some other user then your program may not be able to access it via COM using different credentials. The office applications tend to be single instance which seems to exacerbate this problem.
Retrieving the COM class factory for component.... error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
- Make sure that you have Office runtime installed on the server.
- If you are using Windows Server 2008 then using office interops is a lenghty configuration and here are the steps.
Better is to move to Open XML or you can configure as below
- Install MS Office Pro Latest (I used 2010 Pro)
- Create User ExcelUser. Assign WordUser with Admin Group
- Go to Computer -> Manage
- Add User with below options
- User Options Password Never Expires
- Password Cannot Be Change
Com+ Configuration
- Go to Control Panel - > Administrator -> Component Services -> DCOM Config
- Open Microsoft Word 97 - 2003 Properties
- General -> Authentication Level : None
- Security -> Customize all 3 permissions to allow everyone
- Identity -> This User -> Use ExcelUser /password
- Launch the Excel App to make sure everything is fine
3.Change the security settings of Microsoft Excel Application in DCOM Config.
Controlpanel --> Administrative tools-->Component Services -->computers --> myComputer -->DCOM Config --> Microsoft Excel Application.
Right click to get properties dialog. Go to Security tab and customize permissions
See the posts here: Error while creating Excel object , Excel manipulations in WCF using COM
Accessing Office Word object model through asp.net results in failed due to the following error: 80070005 Access is denied.
This worked for me:
- In the command line put
DCOMCNFG
- Component Services -> Computers -> My Computer -> DCOM Config
- Find "Microsoft Word 97 - 2003 Document" (If it is missing check if your Word is also 64 bit (if your Windows is) if it is not run
mmc comexp.msc /32
instead ofDCOMCNFG
on step 1 as suggested by Darkseal here) - Right click -> Properties
- Go To Tab Security and Edit the "Customize" radio buttons so that IIS_IUSRS could have rights for launch and access
- Go to Tab Identity and choose "The interactive user"
- Apply changes and try again
- If all this fails, go also to tab "General" and in "Authentication Level" drop down choose "None".
Retrieving the COM class factory for component with CLSID failed due to the following error: 80070005 Access is denied
- From the Start menu, click Run and type Dcomcnfg.exe.
- In Component Services, click Console root, expand Component Services, expand Computers, expand My computer,expand DCOMConfig.
- Search for Microsoft Word 14.0 Object Library. Click on it.
- Right click and select Properties.
- On security tab, select Customize in "Launch and Activation" section.
- Click edit and add identity of app pool under which you application is running.
- Repeat above step for "Access Permission"
Related Topics
Get Current Area Name in View or Controller
.Include() VS .Load() Performance in Entityframework
How to Give Read/Write Permissions to a Folder During Installation Using .Net
Using Msbuild to Execute a File System Publish Profile
What Is the Efficiency and Performance of Linq and Lambda Expression in .Net
How to See What My Reactive Extensions Query Is Doing
Iis Wcf Service Hosting VS Windows Service
Is It Secure to Store Passwords in Cookies
Is Configurationmanager.Appsettings Available in .Net Core 2.0
Should I Abstract the Validation Framework from Domain Layer
Cannot Implicitly Convert Type 'Int' to 'T'
How to Get a List of Keys from JSON.Net
Any Reason to Use Auto-Implemented Properties Over Manual Implemented Properties