|
-
Aug 4th, 2011, 01:17 PM
#1
Thread Starter
Member
VB.Net 2010 program .exe wants Excel 2010
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:
Code:
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)
-
Aug 4th, 2011, 02:37 PM
#2
Re: VB.Net 2010 program .exe wants Excel 2010
you need to add a reference to:
Microsoft Excel 12.0 Object Library
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 4th, 2011, 03:05 PM
#3
Re: VB.Net 2010 program .exe wants Excel 2010
Actually, to ensure that your program will work with any version of MS Office, you need to use late binding.
The trick is to reference the object library available in your development machine (Excel 2010 in your case) to take advantage of intellisense why you're writing code. Once done, you remove the reference and fix all the errors that pop out by turning option strict off and use late binding.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|