1

I am using a word automation class on an aspx page to open and edit a word file. The problem is that every time the code hits the open application line, i get the following error:

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

I have looked around a lot for this issue and have tried the DCOMCONFIG settings. The problem is, the Microsoft Word Application setting does not exist under my computer. Is there any way to fix this most frustrating issue? Or is there another way to do this word automation without using word iterop?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
John Baum
  • 3,183
  • 11
  • 42
  • 90
  • You must not use Office Automation from any service application, especially ASP.NET. It was designed for use from a desktop application only, so doesn't understand that it's being used by different users and multiple threads at a time. It's also unsupported and may violate your license agreement, but those are separate from the fact that it will either "just not work", or worse, appear to work but leave you running after unfixable bugs forever. – John Saunders Mar 16 '12 at 15:15
  • See http://stackoverflow.com/questions/9493106/editing-an-excel-document-with-macros-in-asp-net to learn how much work you'll have to go through to make this work, and see http://stackoverflow.com/questions/tagged/office-automation+asp.net in general. – John Saunders Mar 16 '12 at 15:19

2 Answers2

1

Take a look at this http://docx.codeplex.com/

Micah Armantrout
  • 6,781
  • 4
  • 40
  • 66
  • Can docx code be called from an aspx page without any headache? My requirements are to open a word doc, scan it for bookmarks and insert tables at those bookmarks at the click of a button on an aspx page – John Baum Mar 16 '12 at 15:43
  • it is not written around Com so its going to be better to use in asp.net – Micah Armantrout Mar 16 '12 at 16:15
  • Looks like DocX doesn't support bookmarks that I can see check this out http://stackoverflow.com/questions/7026449/replacing-bookmarks-in-docx-file-using-openxml-sdk-and-c-cli – Micah Armantrout Mar 16 '12 at 16:25
0

Not even Microsoft recommends using Office Automation in ASP.net (see this MSDN reference).

You might want to do some more searching here on SO. You could use the OOXML library, found here. There is also (not free) Aspose.words.

Bryan Crosby
  • 6,486
  • 3
  • 36
  • 55