Hi. I am getting errors when writing the codes below:

Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oRng As Excel.Range

' Start Excel and get Application object.
oXL = CreateObject("Excel.Application")
oXL.Visible = True
' Get a new workbook.
oWB = oXL.Workbooks.Add
oSheet = oWB.ActiveSheet

errors: Type Excel.Application is not defined.
the same errors for the other 3 Dim statements.

This is only a small part of the code which I got from microsoft MSDN site.

I had included the MS Excel library 12.0 Object libray reference.

I have done this in VB6 without any problem.

What is wrong with the above Dims? I am using VB2005 and MS Excel 2007.
Thank you.