Pergunta

I am trying to use the Microsoft.Office.Interop.xxxxxxx namespace but Visual Studio 2010 is not providing an option for "interop". I have the PIA's installed for office12 and office14, I have included them in the 'References' in the Solution Explorer, but it is not working.

The code I am trying to call the namespace with is:

    using Excel = Microsoft.Office...;

After "Office.", I am only given the option for "Core". So it would look like this

    using Excel = Microsoft.Office.Core;

This matches the reference that was imported...but using this namespace does not seem to be useful.

My question is how do I get the Microsoft.Office.Interop option to be accepted and display in intellisense?

Example:

    using Excel = Microsoft.Office.Interop.Excel;

Error message being received for 'Interop'= "The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.Office' (are you missing an assembly reference?)

The assembly that I loaded in the Solution Explorer is "Microsoft Office 14.0 Object Library" TypeLib Version 2.5. The assembly path = "C:\Program Files\Common Files\Microsoft Shared\OFFICE14\MSO.DLL

Thanks for any suggestions!

Foi útil?

Solução

You didn't pick the correct reference. Use "Microsoft Excel 14.0 Object Library" instead.

Note that VS2010 supports the Embed Interop Types property for an assembly reference. You really want to use that for an Office app, no PIA required. It is automatically set to True.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top