PC Review


Reply
Thread Tools Rate Thread

Delete OLEObject from Row or Cell

 
 
Liz
Guest
Posts: n/a
 
      28th Mar 2010
Hi,
I have seen how you can delete all oleobjects from an active sheet. But I
cannot figure out how to delete an oleobject (embedded file object) from only
the current row or active cell.

For instance, in my worksheet, most rows in columns c have embedded file
objects. I just want a macro to delete the current row's embedded file
object, not all objects in the active sheet.

Is this possible?

Thanks so much,
Liz
 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      28th Mar 2010
Try something like the following:

Dim OleObj As OLEObject
For Each OleObj In Worksheets("Sheet1").OLEObjects
If OleObj.TopLeftCell.Row = ActiveCell.Row Then
OleObj.Delete
End If
Next OleObj

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com




On Sun, 28 Mar 2010 13:37:01 -0700, Liz
<(E-Mail Removed)> wrote:

>Hi,
>I have seen how you can delete all oleobjects from an active sheet. But I
>cannot figure out how to delete an oleobject (embedded file object) from only
>the current row or active cell.
>
>For instance, in my worksheet, most rows in columns c have embedded file
>objects. I just want a macro to delete the current row's embedded file
>object, not all objects in the active sheet.
>
>Is this possible?
>
>Thanks so much,
>Liz

 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      28th Mar 2010
Hi Liz,

Something like the following might help. You could test both Left and Top
position for an object in an individual cell.

Sub DeleteOleObjsInRow()
Dim oleOBJ As OLEObject
Dim topThisRow As Long
Dim topNextRow As Long

topThisRow = Rows(7).Top
topNextRow = Rows(8).Top

With ActiveSheet
For Each oleOBJ In .OLEObjects
With oleOBJ
If .Top >= topThisRow And .Top <= topNextRow Then
.Delete
End If
End With
Next oleOBJ
End With

End Sub

--
Regards,

OssieMac


"Liz" wrote:

> Hi,
> I have seen how you can delete all oleobjects from an active sheet. But I
> cannot figure out how to delete an oleobject (embedded file object) from only
> the current row or active cell.
>
> For instance, in my worksheet, most rows in columns c have embedded file
> objects. I just want a macro to delete the current row's embedded file
> object, not all objects in the active sheet.
>
> Is this possible?
>
> Thanks so much,
> Liz

 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      28th Mar 2010
Hi again Liz,

That was poor coding that I posted even though it will work because working
with the active sheet anyway. Assigning the .Top to the variables should have
been inside the With ActiveSheet then it is transportable to code that
specifies the sheet name instead of ActiveSheet.

Sub DeleteOleObjsInRow()
Dim oleOBJ As OLEObject
Dim topThisRow As Long
Dim topNextRow As Long

With ActiveSheet
topThisRow = .Rows(7).Top
topNextRow = .Rows(8).Top
For Each oleOBJ In .OLEObjects
With oleOBJ
If .Top >= topThisRow And .Top <= topNextRow Then
.Delete
End If
End With
Next oleOBJ
End With

End Sub


--
Regards,

OssieMac

 
Reply With Quote
 
Liz
Guest
Posts: n/a
 
      31st Mar 2010
Thanks so much for your help!!! I wish I had your skill levels!

"Liz" wrote:

> Hi,
> I have seen how you can delete all oleobjects from an active sheet. But I
> cannot figure out how to delete an oleobject (embedded file object) from only
> the current row or active cell.
>
> For instance, in my worksheet, most rows in columns c have embedded file
> objects. I just want a macro to delete the current row's embedded file
> object, not all objects in the active sheet.
>
> Is this possible?
>
> Thanks so much,
> Liz

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you delete a cell without going Table>Select>Cell then Table>Delete>Cell - phew! JethroUK© Microsoft Frontpage 3 8th Jun 2009 10:58 PM
Getting reference to an OLEObject from another cell? tomerdr@gmail.com Microsoft Excel Programming 3 23rd Apr 2007 11:00 AM
Re: OleObject really embedded in cell - not as shape overlay Jon Peltier Microsoft Excel Programming 1 20th Dec 2006 01:40 PM
OLEObject SG Microsoft Access Forms 0 5th Dec 2006 04:51 PM
OLEObject SG Microsoft Access Form Coding 0 5th Dec 2006 04:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:10 AM.