I want to use excel function in Visual Basic 2010 Express. I tried to search in the internet to see how to do that.
I come across with this solution:
Module Module1
Sub Main()
Imports Excel = Microsoft.Office.Interop.Excel
Dim oXLApp As New Excel.Application
Dim ExcelMath As Excel.WorksheetFunction
ExcelMath = New Excel.WorksheetFunction
Dim I As Double
Dim s As Double
I = ExcelMath.Average(1, 2, 3, 4, 5)
s = ExcelMath.StDev(1, 2, 3, 4, 5)
ExcelMath = Nothing
oXLApp.Quit()
oXLApp = Nothing
End Sub
End Module
However, there is error of:
1. Syntax error.
2. Type ‘Excel.Applciation” is not defined.
3. Type ‘Excel.WorksheetFunction’ is not defined.
How should it be resolved?
Or is there other simple way to do that?
Thanks a lot!
My guess is that you need to add a reference to the Microsoft Excel Object Library. For a brief tutorial, see http://support.microsoft.com/kb/301982 (more specifically, step #3).
If this doesn’t resolve the problem, let us know.