Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Removing Objects

Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I have a
few picture objects. Is there a way that we can write a code to remove all
the picture objects in the worksheets of the workbook?

Thanks.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Removing Objects

Ron,

Looking at that link I see that you quote some code from Dave P and myself
regarding deleting shapes (Shapes4). Your example is for Forms controls
only, whereas we have posted code for both Forms and Control Toolbox. I
didn't read the item in depth, it may be you were only looking for Forms
shapes, but just in case, I enclose the full code (PS it does still preserve
data validation and autofilter dropdown arrows <G)

Sub DeleteShapes()

Dim shp As Shape
Dim testStr As String
Dim OkToDelete As Boolean

For Each shp In ActiveSheet.Shapes
OkToDelete = True

testStr = ""
On Error Resume Next
testStr = shp.TopLeftCell.Address
On Error GoTo 0

If shp.Type = msoFormControl Then
If shp.FormControlType = xlDropDown Then
If testStr = "" Then
'keep it
OkToDelete = False
End If
End If
End If

If OkToDelete Then
shp.Delete
End If

Next shp

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ron de Bruin" wrote in message
...
Hi Please Help

Look here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" <Please wrote in message

...
Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I have

a
few picture objects. Is there a way that we can write a code to remove

all
the picture objects in the worksheets of the workbook?

Thanks.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Removing Objects


Hi Bob

The example is only for Forms controls Bob on the page because there is the problem
I maybe add it after I update the page with 2007 stuff

I have send you a private mail Bob

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Bob Phillips" wrote in message ...
Ron,

Looking at that link I see that you quote some code from Dave P and myself
regarding deleting shapes (Shapes4). Your example is for Forms controls
only, whereas we have posted code for both Forms and Control Toolbox. I
didn't read the item in depth, it may be you were only looking for Forms
shapes, but just in case, I enclose the full code (PS it does still preserve
data validation and autofilter dropdown arrows <G)

Sub DeleteShapes()

Dim shp As Shape
Dim testStr As String
Dim OkToDelete As Boolean

For Each shp In ActiveSheet.Shapes
OkToDelete = True

testStr = ""
On Error Resume Next
testStr = shp.TopLeftCell.Address
On Error GoTo 0

If shp.Type = msoFormControl Then
If shp.FormControlType = xlDropDown Then
If testStr = "" Then
'keep it
OkToDelete = False
End If
End If
End If

If OkToDelete Then
shp.Delete
End If

Next shp

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ron de Bruin" wrote in message
...
Hi Please Help

Look here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" <Please wrote in message

...
Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I have

a
few picture objects. Is there a way that we can write a code to remove

all
the picture objects in the worksheets of the workbook?

Thanks.







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Removing Objects

Yeah, thanks I have it. Will reply tonight.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ron de Bruin" wrote in message
...

Hi Bob

The example is only for Forms controls Bob on the page because there is

the problem
I maybe add it after I update the page with 2007 stuff

I have send you a private mail Bob

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Bob Phillips" wrote in message

...
Ron,

Looking at that link I see that you quote some code from Dave P and

myself
regarding deleting shapes (Shapes4). Your example is for Forms controls
only, whereas we have posted code for both Forms and Control Toolbox. I
didn't read the item in depth, it may be you were only looking for Forms
shapes, but just in case, I enclose the full code (PS it does still

preserve
data validation and autofilter dropdown arrows <G)

Sub DeleteShapes()

Dim shp As Shape
Dim testStr As String
Dim OkToDelete As Boolean

For Each shp In ActiveSheet.Shapes
OkToDelete = True

testStr = ""
On Error Resume Next
testStr = shp.TopLeftCell.Address
On Error GoTo 0

If shp.Type = msoFormControl Then
If shp.FormControlType = xlDropDown Then
If testStr = "" Then
'keep it
OkToDelete = False
End If
End If
End If

If OkToDelete Then
shp.Delete
End If

Next shp

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ron de Bruin" wrote in message
...
Hi Please Help

Look here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" <Please wrote in message

...
Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I

have
a
few picture objects. Is there a way that we can write a code to

remove
all
the picture objects in the worksheets of the workbook?

Thanks.










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Removing Objects

Thanks both. The code works.

"Ron de Bruin" wrote:


Hi Bob

The example is only for Forms controls Bob on the page because there is the problem
I maybe add it after I update the page with 2007 stuff

I have send you a private mail Bob

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Bob Phillips" wrote in message ...
Ron,

Looking at that link I see that you quote some code from Dave P and myself
regarding deleting shapes (Shapes4). Your example is for Forms controls
only, whereas we have posted code for both Forms and Control Toolbox. I
didn't read the item in depth, it may be you were only looking for Forms
shapes, but just in case, I enclose the full code (PS it does still preserve
data validation and autofilter dropdown arrows <G)

Sub DeleteShapes()

Dim shp As Shape
Dim testStr As String
Dim OkToDelete As Boolean

For Each shp In ActiveSheet.Shapes
OkToDelete = True

testStr = ""
On Error Resume Next
testStr = shp.TopLeftCell.Address
On Error GoTo 0

If shp.Type = msoFormControl Then
If shp.FormControlType = xlDropDown Then
If testStr = "" Then
'keep it
OkToDelete = False
End If
End If
End If

If OkToDelete Then
shp.Delete
End If

Next shp

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ron de Bruin" wrote in message
...
Hi Please Help

Look here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" <Please wrote in message

...
Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I have

a
few picture objects. Is there a way that we can write a code to remove

all
the picture objects in the worksheets of the workbook?

Thanks.







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Removing Objects

Ron,

Your code and Bob's code work well, except I have a little problem. How can
we modify it to exclude from deleting text boxes? I only want to delete
picture objects, neither forms or control objects.

Thanks.

"Ron de Bruin" wrote:

Hi Please Help

Look here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" <Please wrote in message ...
Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I have a
few picture objects. Is there a way that we can write a code to remove all
the picture objects in the worksheets of the workbook?

Thanks.




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Removing Objects

Try this


Sub Shapes2()
'Loop through the Shapes collection and use the Type number of the control
Dim myshape As Shape
For Each myshape In ActiveSheet.Shapes

' Pictures
If myshape.Type = 13 Then myshape.Delete

Next myshape
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" wrote in message ...
Ron,

Your code and Bob's code work well, except I have a little problem. How can
we modify it to exclude from deleting text boxes? I only want to delete
picture objects, neither forms or control objects.

Thanks.

"Ron de Bruin" wrote:

Hi Please Help

Look here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" <Please wrote in message ...
Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I have a
few picture objects. Is there a way that we can write a code to remove all
the picture objects in the worksheets of the workbook?

Thanks.






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Removing Objects

Ron,

You are the best. Thank you very much. It works.

By the way, where can I go to find out what shape type is what #.

Thanks.

"Ron de Bruin" wrote:

Try this


Sub Shapes2()
'Loop through the Shapes collection and use the Type number of the control
Dim myshape As Shape
For Each myshape In ActiveSheet.Shapes

' Pictures
If myshape.Type = 13 Then myshape.Delete

Next myshape
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" wrote in message ...
Ron,

Your code and Bob's code work well, except I have a little problem. How can
we modify it to exclude from deleting text boxes? I only want to delete
picture objects, neither forms or control objects.

Thanks.

"Ron de Bruin" wrote:

Hi Please Help

Look here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" <Please wrote in message ...
Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I have a
few picture objects. Is there a way that we can write a code to remove all
the picture objects in the worksheets of the workbook?

Thanks.






  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Removing Objects

Look for msoShapeType in the object browser, all listed there.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ron de Bruin" wrote in message
...
Try this


Sub Shapes2()
'Loop through the Shapes collection and use the Type number of the control
Dim myshape As Shape
For Each myshape In ActiveSheet.Shapes

' Pictures
If myshape.Type = 13 Then myshape.Delete

Next myshape
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" wrote in message

...
Ron,

Your code and Bob's code work well, except I have a little problem. How

can
we modify it to exclude from deleting text boxes? I only want to delete
picture objects, neither forms or control objects.

Thanks.

"Ron de Bruin" wrote:

Hi Please Help

Look here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" <Please wrote in message

...
Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I

have a
few picture objects. Is there a way that we can write a code to

remove all
the picture objects in the worksheets of the workbook?

Thanks.









  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Removing Objects

List is on my site

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" wrote in message ...
Ron,

You are the best. Thank you very much. It works.

By the way, where can I go to find out what shape type is what #.

Thanks.

"Ron de Bruin" wrote:

Try this


Sub Shapes2()
'Loop through the Shapes collection and use the Type number of the control
Dim myshape As Shape
For Each myshape In ActiveSheet.Shapes

' Pictures
If myshape.Type = 13 Then myshape.Delete

Next myshape
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" wrote in message ...
Ron,

Your code and Bob's code work well, except I have a little problem. How can
we modify it to exclude from deleting text boxes? I only want to delete
picture objects, neither forms or control objects.

Thanks.

"Ron de Bruin" wrote:

Hi Please Help

Look here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" <Please wrote in message
...
Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I have a
few picture objects. Is there a way that we can write a code to remove all
the picture objects in the worksheets of the workbook?

Thanks.








  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Removing Objects

I got it. What is the different between 11 (msoLinkedPicture) and 13
(msoPicture)?

Thanks both.

"Bob Phillips" wrote:

Look for msoShapeType in the object browser, all listed there.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ron de Bruin" wrote in message
...
Try this


Sub Shapes2()
'Loop through the Shapes collection and use the Type number of the control
Dim myshape As Shape
For Each myshape In ActiveSheet.Shapes

' Pictures
If myshape.Type = 13 Then myshape.Delete

Next myshape
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" wrote in message

...
Ron,

Your code and Bob's code work well, except I have a little problem. How

can
we modify it to exclude from deleting text boxes? I only want to delete
picture objects, neither forms or control objects.

Thanks.

"Ron de Bruin" wrote:

Hi Please Help

Look here
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Please Help" <Please wrote in message

...
Hello,

I have a workbook that contains 5 worksheets. In each worksheet, I

have a
few picture objects. Is there a way that we can write a code to

remove all
the picture objects in the worksheets of the workbook?

Thanks.








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
removing objects..! via135 via OfficeKB.com Excel Discussion (Misc queries) 2 March 15th 10 05:06 PM
Removing patterns without removing gridlines pennyb9 Excel Discussion (Misc queries) 1 July 11th 07 02:43 AM
Dynamically Assign Objects to Form Objects. The Vision Thing Excel Programming 2 December 11th 04 04:02 PM
Unable to remove Sheet objects in the Microsoft Excel Objects Adrian[_7_] Excel Programming 1 August 26th 04 10:49 PM
Removing objects without unmerging cells No Name Excel Programming 2 May 26th 04 07:21 PM


All times are GMT +1. The time now is 01:00 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"