Excel not working? What gives

  • Thread starter Thread starter Brent
  • Start date Start date
B

Brent

Having used every combonation of excel 9/10/11 and office 10/11 possible as
references i still can not create an excel object! Any ideas?

Just using this simple bit below i get "Excel.appication not defined"

dim xlApp as Excel.Application, xlWs as Excel.WorkSheet
set xlApp = new Excel.Application
 
Hi Brent,

Don't use 'set':
Dim objxl As Excel.Application

Dim objwbs As Excel.Workbooks

Dim objwb As Excel.Workbook

Dim objws As Excel.Worksheet



objxl = New Excel.Application

This worked for me.

HTH,

Bernie Yaeger
 
same error with your method as well.. it underlines excel.application in the
first line as if it somehow is not accessing the references :(
 
You probably don't have a reference to the COM Excel wrapper in your
References for the project.

This works for me, but it uses COM, and I don't know if .Net has direct
support for Excel yet:

1. Open Solution Explorer.
2. In the Project, right-click on References and choose Add Reference.
3. Select the COM tab.
4. Scroll down until you see Microsoft Excel <whatever> (Hint: type the
letter "M" to quickly scroll near to where you need to be in the list).
5. Highlight the Microsoft Excel entry (I had two, one for Excel 5 and one
for Excel 8) and click Select.
6. Click OK to close the dialog.

Open up a module and type the following

dim justatest as

As soon as you type the word "as", Intellisense should pop up and allow you
to type the letters Ex and the selection list should scroll to
Excel.Application. I just did this little exercise on a sample project that
had nothing to do with Excel and it works fine.
 
* "Brent said:
Having used every combonation of excel 9/10/11 and office 10/11 possible as
references i still can not create an excel object! Any ideas?

Just using this simple bit below i get "Excel.appication not defined"

dim xlApp as Excel.Application, xlWs as Excel.WorkSheet
set xlApp = new Excel.Application

HOWTO: Automate Microsoft Excel from Visual Basic .NET
<http://support.microsoft.com/default.aspx?scid=kb;en-us;301982>
 
I'mt telling ya, this is the weirdest thing.. I have clearly refrenced the
required excel object, however, excel.anything doesnt exist in the
autocomplete. Excel doesn't exist in the autocomplete..

Dim test as (no excel in autocomplete here)
--------------
Ahh it finally worked

I had to use the full namespace for some reason to get to it..

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



Thats the only way i was able to create an excel object... Any idea why I
have to do it this way?
 
Hi Brent,

Try removing your reference and then readding it. My guess is you did not
have the com object loaded, or else you had one that was misbehaving.

Bernie

Brent said:
I'mt telling ya, this is the weirdest thing.. I have clearly refrenced the
required excel object, however, excel.anything doesnt exist in the
autocomplete. Excel doesn't exist in the autocomplete..

Dim test as (no excel in autocomplete here)
--------------
Ahh it finally worked

I had to use the full namespace for some reason to get to it..

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



Thats the only way i was able to create an excel object... Any idea why I
have to do it this way?







possible
 
Back
Top