You have not qualified the object names so the system knows which types you are referring to. Try changing the
Dim
statements to:
Dim excel As Microsoft.Office.Interop.Excel.Application = New Microsoft.Office.Interop.Excel.Application
Dim workbook As Microsoft.Office.Interop.Excel.Workbook = New Microsoft.Office.Interop.Excel.Workbook
Dim worksheet As Microsoft.Office.Interop.Excel.Worksheet = workbook.ActiveSheet
[edit]
Here is a tested sample that should do what you want:
Imports System.IO
Imports Excel = Microsoft.Office.Interop.Excel
Module XLTest
Sub Main()
Dim xlApp As Excel.Application = New Excel.Application()
If xlApp Is Nothing Then
Console.WriteLine("Error: Excel is not properly installed.")
Return
End If
Dim xlWorkBook As Excel.Workbook
xlWorkBook = xlApp.Workbooks.Add(Type.Missing)
Dim xlWorkSheet = xlWorkBook.Sheets.Add(Type.Missing)
xlWorkSheet.Cells(1, 1) = "Value1"
xlWorkSheet.Cells(2, 1) = "Value2"
xlWorkBook.SaveAs("d:\Actor.xlsx")
xlWorkBook.Close(True, Type.Missing, Type.Missing)
xlApp.Quit()
Console.WriteLine("Excel test complete")
End Sub
End Module
[/edit]