Problem to create Excel file

Hi,
I'm to create Excel file by C# codes and have got this

Error	1	Assembly 'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' uses 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' which has a higher version than referenced assembly 'office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
Error	2	Assembly 'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' uses 'Microsoft.Vbe.Interop, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' which has a higher version than referenced assembly 'Microsoft.Vbe.Interop, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

Open in new window

using these codes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
using Microsoft.Office.Interop;
using Excel = Microsoft.Office.Interop.Excel;

namespace ns1
{
    class Program
    {
        static void Main(string[] args)
        {
            string orp_path = "//ABC";
            bool allowappend = true;

            string test = "test";
            Excel.Application app = null;
            Excel.Workbook workbook = null;
            Excel.Worksheet worksheet = null;
            Excel.Range workSheet_range = null;
            object misValue = System.Reflection.Missing.Value;

            Excel.Application xlApp = new
            Microsoft.Office.Interop.Excel.Application();
            workbook = xlApp.Workbooks.Add(misValue);

            workbook = xlApp.Workbooks.Add(misValue);
            worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item(1);
            
            worksheet.Cells[1, 1] = "Run Date";

            workbook.SaveAs("c:\\" + test + ".xls", Excel.XlFileFormat.xlOpenXMLTemplate, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            workbook.Close(true, misValue, misValue);
            xlApp.Quit();

            releaseObject(worksheet);
            releaseObject(workbook);
            releaseObject(xlApp);
            ...

Open in new window



on VS 2013. Any advice?
LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Try if including those implicit references explicitly before line 12 helps.
However, there seem to be an error in the reference info, as the 15 one should be used by default when installed. Maybe you require a repair install of Office.
0
ThommyCommented:
The message says, that you are trying to compile against Office 2013 Interop (Version=15.0) but your project is using the wrong dll (Office 2007 Interop Version=12.0)!!!

Try re-installing Office 2013 and turn on the ".NET Programmability Support" to get Microsoft.Office.Interop.Excel Version 15.0.0.0 reinstalled.
0
HuaMin ChenProblem resolverAuthor Commented:
Thanks all.
Thommy,
is it OK if I set up Office 2010 for this? If OK, what to adjust next?
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

HuaMin ChenProblem resolverAuthor Commented:
If not, how to adjust the codes, to still use the current MS Office version?
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
You can set up Office 2010, but that needs to be the only version you have on the dev system, or you have to select the version in your USING statement (not recommended - that exact version is required then on any target system).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ThommyCommented:
Sorry, I was a little bit late!

I do absolutely confirm Olemo's words.

Why do you want to install Office 2010?
Thought you already have Office 2013 installed?
0
HuaMin ChenProblem resolverAuthor Commented:
Sorry, I compile the same codes, within another machine, on which I've set up Office 2010, but I still get these below
Error	1	Assembly 'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' uses 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' which has a higher version than referenced assembly 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'	
Error	2	Assembly 'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' uses 'Microsoft.Vbe.Interop, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' which has a higher version than referenced assembly 'Microsoft.Vbe.Interop, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'	

Open in new window

0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
I'm confused. Are you still having that issue, even on another machine with Ofiice 2010 installed?
0
HuaMin ChenProblem resolverAuthor Commented:
Yes, OK to the problem already.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.