0

Currently we have a remote box executing a console application. This console executes various Excel macros - these macros are in Excel 2010 files - and the remote box has Excel 2010 installed.

I now have Excel 2013 on my PC and have added some features to one of our xl files. This is not running via the console.

The console has a reference to Microsoft.Office.Interop.Excel 14.0.0.0 and within the Program I use the following:

using Excel = Microsoft.Office.Interop.Excel;
...
...
Excel.Application excelApp = null;
...
...
excelApp = new Excel.Application();

I believe this will need to change. Hopefully I'm reading @HansPassant (ref: Can I still use Microsoft.Office.Interop assemblies with office 2013?) correctly but I'll need to:

  1. Drop the reference to Microsoft.Office.Interop.Excel v14.0.0.0
  2. Add a reference to Microsoft Excel 15.0 Object Library v1.8

If I make this change will the console be able to run macros in both Excel 2010 and Excel 2013 files?

How will the above code snippet change once I move from interop to this COM reference?

Community
  • 1
  • 1
whytheq
  • 34,466
  • 65
  • 172
  • 267

1 Answers1

1

I just sticked to the old interop assembly. But within the properties of the reference set

This should create an assembly on the fly, which only contains the methods and types that you are actually using withing your code. On start-up it tries to find an assembly with the same name but takes the highest version it gets (hence the specific version is false) and bridges from your type to the type within that assembly.

So if you only use excel features that are available already in an older version you should be able to work with Excel 2003, 2007, whatever.

Community
  • 1
  • 1
Oliver
  • 43,366
  • 8
  • 94
  • 151
  • when run on my pc (with 2013 installed) it is still erroring - in fact whichever route I take COM or .NET extension I get a internal excel error. I'm going to try to isolate which part of the process is causing the error. – whytheq Oct 29 '14 at 10:53