[RESOLVED] Not able to use 'Set' when using Excel object
Hi people,
I wonder if I missing any rerfence or something?
anyway I am not able to use "Set" in my code example:
I have made following code:
Code:
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlApp As Excel.Application
Dim wb As Workbook
Dim ws As Worksheet
Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Add
Set ws = wb.Worksheets("Sheet1")
end sub
end class
Could someone help me why?
Re: Not able to use 'Set' when using Excel object
It's OK, just leave it out... the Set keyword is for old versions of VB (1998 and earlier) or VBA, you don't need it in VB.Net
Set is about telling VB/VBA you are using Objects, but as .Net is object oriented you don't need to tell it.