Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Liz Liz is offline
external usenet poster
 
Posts: 133
Default Delete OLEObject from Row or Cell

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Delete OLEObject from Row or Cell

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
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Delete OLEObject from Row or Cell

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Delete OLEObject from Row or Cell

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
Liz Liz is offline
external usenet poster
 
Posts: 133
Default Delete OLEObject from Row or Cell

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting reference to an OLEObject from another cell? [email protected] Excel Programming 3 April 23rd 07 11:00 AM
OleObject really embedded in cell - not as shape overlay Jon Peltier Excel Programming 1 December 20th 06 01:40 PM
FollowHyperlink to OLEObject Tony Excel Programming 0 January 5th 05 10:15 PM
OLEObject GetFocus Erich Neuwirth Excel Programming 1 August 11th 04 08:18 PM
OLEobject on the sheet Ryan[_6_] Excel Programming 1 August 3rd 03 03:15 PM


All times are GMT +1. The time now is 07:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"