Results 1 to 2 of 2

Thread: [RESOLVED] Not able to use 'Set' when using Excel object

  1. #1

    Thread Starter
    Lively Member elmnas's Avatar
    Join Date
    Jul 2009
    Posts
    127

    Resolved [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?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width