Bryan Torres
Bryan Torres

Reputation: 11

Attempting to import Microsoft Office into my ASP.NET project fails

Imports Microsoft.Office.Interop.Word

I am building an ASP.NET MVC application and the above code gives me an error, with no error message or error code. I'm simply unable to create Word objects. I've already imported my references to Microsoft Office 14.0 Object Library and that did not help. Can anyone offer some insight why I'm unable to import Microsoft Office?

Upvotes: 0

Views: 126

Answers (1)

welegan
welegan

Reputation: 3043

1) Make sure you have Microsoft Office installed, or it won't work, even if you get it to build. Why is that? Because the Office.Interop library is meant for automation of tasks in Office, usually for plugins and things written for windows forms applications. If you are trying to do this in ASP.NET MVC, I am assuming that you actually want to just generate a Word document, not automate some task within the actual Word application itself. To do this, you should not use the Office.Interop reference, but rather

2) Go download the Microsoft OpenXml sdk. Here is a link:

http://www.microsoft.com/en-us/download/details.aspx?id=30425

And a reference site for the actual format:

http://openxmldeveloper.org/

And a very helpful tool for debugging various open xml documents:

http://www.microsoft.com/en-us/download/details.aspx?id=30425

Upvotes: 1

Related Questions