Creating an Excel Workbook in VB.NET 2008
-
Hi, I'm helping a colleague of mine. We're trying to create an Excel workbook so he can do some calculations. However, we can't get the excel object to instantiate. We've added the reference via 'Project->Add Reference->Microsoft Excel 11.0 Object Library->OK. On our form, we've added the following but can not get the object to instantiate. Imports Microsoft.Office.Interop.Excel Public Class Form1 Dim excelapp As New Microsoft.Office.Interop.Excel.Application Dim excelwb As Microsoft.Office.Interop.Excel.Workbook End Class The Dim calls seem to take ok as no squiggly lines appear on those two lines. Attempting to reference excelapp or excelwb only results in squiggly lines under their names and no properties will appear in the drop down - that is, there is no dropdown as it doesn't recognize the two variables. How can we instantiate the excel object so we can use the methods on it? Thanks in advance. :)
-
Hi, I'm helping a colleague of mine. We're trying to create an Excel workbook so he can do some calculations. However, we can't get the excel object to instantiate. We've added the reference via 'Project->Add Reference->Microsoft Excel 11.0 Object Library->OK. On our form, we've added the following but can not get the object to instantiate. Imports Microsoft.Office.Interop.Excel Public Class Form1 Dim excelapp As New Microsoft.Office.Interop.Excel.Application Dim excelwb As Microsoft.Office.Interop.Excel.Workbook End Class The Dim calls seem to take ok as no squiggly lines appear on those two lines. Attempting to reference excelapp or excelwb only results in squiggly lines under their names and no properties will appear in the drop down - that is, there is no dropdown as it doesn't recognize the two variables. How can we instantiate the excel object so we can use the methods on it? Thanks in advance. :)
I tried the following;
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Dim excel As New Microsoft.Office.Interop.Excel.Application Private Sub Form1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load excel.Visible = True End Sub
End Class
And excel application opens fine and becomes visible when Form1 loads. If you put excel.visible in your form load event as a test does that work?
Dave Who am I?: http://www.bebo.com/daveauld/
-
I tried the following;
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Dim excel As New Microsoft.Office.Interop.Excel.Application Private Sub Form1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load excel.Visible = True End Sub
End Class
And excel application opens fine and becomes visible when Form1 loads. If you put excel.visible in your form load event as a test does that work?
Dave Who am I?: http://www.bebo.com/daveauld/