Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Type excel.application is not defined

Posted on 2012-03-16
4
Medium Priority
?
638 Views
Last Modified: 2012-03-19
Hi,

I'm using visual basic 2010, I'm trying to use excel from Vb.net but I keep getting the following error when using the following code: type excel.application is not defined

dim xl as excel.application
dim wb as excel.workbook
dim ws as excel.worksheet

I've added the following references:
Microsoft Excel 14.0 Object Library
Microsoft Office 14.0 Object Library
Microsoft visual basic for application s extensibility 5.3
micrisoft.office.interop.excel

and then imported the following :
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop
Imports System.Data

I use word without any issues :

Dim appWord As Word.Application
Dim docWord As Word.Document

How come excel doesn't work the same way?
0
Comment
Question by:FCapo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37729815
I believe you also need the import:

Imports Microsoft.Office.Interop.Excel
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37729826
Actually, strike that. I read your declarations incorrectly.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37730203
That is strange. It should work.

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel(v=office.11).aspx

what happens if you import

Imports Microsoft.Office.Interop.Excel

and then use just application?
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1500 total points
ID: 37732326
Is the last reference a mistake in your question? You should not reference the Interop, only Excel.

The Import is not an absolute condition, it simply enables you to use the classes in the library without having to give the namespace everytime. If the following is working, then simply adding an import to Microsoft.Office.Interop.Excel will enable you to use the syntax that you wanted:

Dim xl As Microsoft.Office.Interop.Excel.Application

But if this does not work, then your reference is not good.

Office applications are very touch about the version that is referenced. If the Excel version you have on the computer on which the application is running is not the same as the one you used for your reference, then you will end up with problems. You will have either to adjust the reference or use late binding (declaring variables as Object).
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question