Results 1 to 2 of 2

Error: "Object Variable or With Block variable not set"

Threaded View

  1. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Hans,

    OLEObjects have an Object property. Setting an object variable equal to this property allows you to acces the methods, events, and properties of the object it represents. Here are the corrections to your code.

    Public Sub Worksheet_SelectionChange(ByVal Target As Range)
    
      Dim ole As Object
      Dim obj As Object
    
        If Target.Column > 1 And Target.Column < 9 _
           And Target.Row > 1 And _ 
           Range("A" & (Target.Row)).Value <> "" 
        Then
    
     'Remove all OLEObjects from sheet
        For Each ole In ActiveSheet.OLEObjects
          Set obj = ole.Object
            If Not (ActiveCell Is Nothing) Then
               MsgBox (obj.Value)
            End If
          obj.Delete
        Next ole
       
         CreateListBox (Target.Cells(1))
    
    End Sub
    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 06-03-2007 at 06:20 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1