Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default deleting objects using VBA


LS,

I'm looking for VBA code with which I can delete shapes (or any othe
object like inserted pictures) when they are/were placed within a rang
of selected cells.

If this doesnot make my problem clear the following description migh
help.
I'd like to select a range of cells (say A3:G50) and be able to delet
any object that is present 'in' this range using VBA code.

Thanks in advance for your help.

Coen van der Weijde

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default deleting objects using VBA

Hi Coen van der Weijden,

Here's a subroutine that should do what you're looking for:

Sub RemoveObjectsFromSelection()
Dim ole As OLEObject
Dim shp As Shape

For Each ole In Selection.Parent.OLEObjects
If Not Application.Intersect(Selection, _
ole.TopLeftCell) Is Nothing Then
ole.Delete
End If
Next ole

For Each shp In Selection.Parent.Shapes
If Not Application.Intersect(Selection, _
shp.TopLeftCell) Is Nothing Then
shp.Delete
End If
Next shp
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


cweijden wrote:
LS,

I'm looking for VBA code with which I can delete shapes (or any other
object like inserted pictures) when they are/were placed within a
range of selected cells.

If this doesnot make my problem clear the following description might
help.
I'd like to select a range of cells (say A3:G50) and be able to delete
any object that is present 'in' this range using VBA code.

Thanks in advance for your help.

Coen van der Weijden


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from
http://www.ExcelForum.com/

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
Excel 2002: Any faster way of deleting floating objects? Mr. Low Excel Discussion (Misc queries) 7 July 18th 08 04:32 PM
Deleting Objects all at once - (copied HTML to excel) coastal Excel Discussion (Misc queries) 4 June 26th 07 08:26 PM
Deleting HTML form objects? GeorgeM Excel Discussion (Misc queries) 3 December 29th 06 11:24 PM
Deleting Objects Copied from Web Page Tim Childs Excel Discussion (Misc queries) 3 February 21st 06 10:49 PM
Deleting name-objects Tom Excel Programming 5 November 24th 03 07:18 PM


All times are GMT +1. The time now is 09:18 AM.

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"