9 Replies - 8061 Views - Last Post: 04 August 2011 - 01:35 PM Rate Topic: -----

#1 LarsB  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 04-August 11

VB.Net 2010 program .exe wants Excel 2010

Posted 04 August 2011 - 10:53 AM

VB.Net 2010 program .exe on PC with Excel 2007 gives error when cannot
find Excel version 14, which is Excel 2010

I have developed a program in VB.Net 2010 which reads from an Excel
spreadsheet. It works fine in the IDE on my computer. I built an
.msi and executed it on my computer. I get "Error: 53 - Could not
load file or assembly 'Microsoft.Office.Interop.Excel,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or
one of its dependencies. The system cannot find the file specified."

The only version of Excel on my computer is 2007, which is version
12.0.6557.5000. The version the error says it needs, version 14, is
actually the version of Excel 2010.

I have put in MsgBox statements to find where the error occurs.

These lines are in the .vb file:

Imports System.Console
Imports System.IO
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Windows.Forms
Imports System.Windows.Forms.Button
Imports System.Windows.Forms.CheckBox
Imports Microsoft.Office.Interop

The error occurs when a routine is called which has the following 
statements:
        Dim xlApp As Excel.Application
        Dim xlWorkBook As Excel.Workbook
        Dim xlWorkSheet As Excel.Worksheet

These statements are also in the file:
        xlApp = New Excel.ApplicationClass
        xlWorkBook = 
	   xlApp.Workbooks.Open(sDatabaseNames(iThisDatabase), , True)
        sWorkbookName = sDatabaseNames(iThisDatabase)

        For iCurrentWorksheet = 1 To xlWorkBook.Worksheets.Count
            xlWorkSheet = xlWorkBook.Worksheets(iCurrentWorksheet)
            sWorksheetName = xlWorkSheet.Name

           range = xlWorkSheet.UsedRange
           rngSearchRange = range.Find(What:=sSearchPhrase)



Is This A Good Question/Topic? 0
  • +

Replies To: VB.Net 2010 program .exe wants Excel 2010

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9580
  • View blog
  • Posts: 36,300
  • Joined: 12-June 08

Re: VB.Net 2010 program .exe wants Excel 2010

Posted 04 August 2011 - 11:08 AM

Perhaps install the assemblies it is asking for, or use a control that isn't marked for a version you don't have.

http://www.microsoft...ls.aspx?id=3508
Was This Post Helpful? 0
  • +
  • -

#3 LarsB  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 04-August 11

Re: VB.Net 2010 program .exe wants Excel 2010

Posted 04 August 2011 - 11:29 AM

View PostLarsB, on 04 August 2011 - 10:53 AM, said:

VB.Net 2010 program .exe on PC with Excel 2007 gives error when cannot
find Excel version 14, which is Excel 2010

I have developed a program in VB.Net 2010 which reads from an Excel
spreadsheet. It works fine in the IDE on my computer. I built an
.msi and executed it on my computer. I get "Error: 53 - Could not
load file or assembly 'Microsoft.Office.Interop.Excel,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or
one of its dependencies. The system cannot find the file specified."

The only version of Excel on my computer is 2007, which is version
12.0.6557.5000. The version the error says it needs, version 14, is
actually the version of Excel 2010.

I have put in MsgBox statements to find where the error occurs.

These lines are in the .vb file:

Imports System.Console
Imports System.IO
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Windows.Forms
Imports System.Windows.Forms.Button
Imports System.Windows.Forms.CheckBox
Imports Microsoft.Office.Interop

The error occurs when a routine is called which has the following 
statements:
        Dim xlApp As Excel.Application
        Dim xlWorkBook As Excel.Workbook
        Dim xlWorkSheet As Excel.Worksheet

These statements are also in the file:
        xlApp = New Excel.ApplicationClass
        xlWorkBook = 
	   xlApp.Workbooks.Open(sDatabaseNames(iThisDatabase), , True)
        sWorkbookName = sDatabaseNames(iThisDatabase)

        For iCurrentWorksheet = 1 To xlWorkBook.Worksheets.Count
            xlWorkSheet = xlWorkBook.Worksheets(iCurrentWorksheet)
            sWorksheetName = xlWorkSheet.Name

           range = xlWorkSheet.UsedRange
           rngSearchRange = range.Find(What:=sSearchPhrase)


Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9580
  • View blog
  • Posts: 36,300
  • Joined: 12-June 08

Re: VB.Net 2010 program .exe wants Excel 2010

Posted 04 August 2011 - 11:31 AM

What? Misplaced your text?
Was This Post Helpful? 0
  • +
  • -

#5 LarsB  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 04-August 11

Re: VB.Net 2010 program .exe wants Excel 2010

Posted 04 August 2011 - 11:32 AM

I cannot install the assembly, which according to asking for version 14 must be Excel 2010. Everyone in the company has Excel 20007 and this will be installed on user computers.

According to my code, I do not think I requesting a specific version of Excel. This runs fine in the IDE.
Was This Post Helpful? 0
  • +
  • -

#6 LarsB  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 04-August 11

Re: VB.Net 2010 program .exe wants Excel 2010

Posted 04 August 2011 - 11:38 AM

What text are you referring to?
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9580
  • View blog
  • Posts: 36,300
  • Joined: 12-June 08

Re: VB.Net 2010 program .exe wants Excel 2010

Posted 04 August 2011 - 11:41 AM

Post 3 is just you re-quoting again. It made no sense besides waste space.

Well go into your references, find where you are referencing the 2010 dlls and switch them to the 2007. Recompile and off you go.
Was This Post Helpful? 2
  • +
  • -

#8 LarsB  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 04-August 11

Re: VB.Net 2010 program .exe wants Excel 2010

Posted 04 August 2011 - 12:10 PM

Thanks. That worked.

However, that raises questions for me:
1. Does this mean my .msi will distribute Excel 2007? It is already on all the users' computers and I should not be distributing it. (I do not have Excel 2010 on
my computer for it to have distributed it.)

2. When the company upgrades Excel on the users' computers to version 2010, will my program break because it has a reference to Excel 2007?

Sorry about that re-quoting. I am new to this.
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9580
  • View blog
  • Posts: 36,300
  • Joined: 12-June 08

Re: VB.Net 2010 program .exe wants Excel 2010

Posted 04 August 2011 - 12:15 PM

I have no idea what is in your MSI or what you rolled with it. Your average MSI won't install anything extra and just uses what's on there. If Excel 07 is not on the target pc then the app will break... or be forced to install the assemblies.

In theory it shouldn't break since most are backwards compatible... I would suggest testing it on a virtual PC or something to be certain.
Was This Post Helpful? 1
  • +
  • -

#10 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Re: VB.Net 2010 program .exe wants Excel 2010

Posted 04 August 2011 - 01:35 PM

This may be stupid comment but he goes have you check though Google to see what problems other people have got with error 53 and looked at their problem to see if you my of forgot to add something or something in your code conflicts with something else ( just a thought good luck)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1