Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Capture Forms button caption

Excel XP & Win XP
I have a number of Forms buttons on a sheet. I want to delete those buttons
that have a specific caption. To do that I must first capture the caption.
The following code is a simplification of what I need. It doesn't work
because the "Caption" line is not right. How would I write the code to
capture the caption? If I can't capture the caption, I could use the
assigned macro name. How would I do that?
Thanks for your time. Otto
Sub RemoveButtons()
Dim ShapeA As Shape
For Each ShapeA In ActiveSheet.Shapes
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Capture Forms button caption

Otto,

Where are these buttons from?

If the forms menu, use

Sub RemoveButtons()
Dim ShapeA As Button
For Each ShapeA In ActiveSheet.Buttons
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub


If from the control toolbox, use

Sub RemoveButtons()
Dim ShapeA As OLEObject
For Each ShapeA In ActiveSheet.OLEObjects
If ShapeA.Object.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
I have a number of Forms buttons on a sheet. I want to delete those
buttons that have a specific caption. To do that I must first capture the
caption. The following code is a simplification of what I need. It
doesn't work because the "Caption" line is not right. How would I write
the code to capture the caption? If I can't capture the caption, I could
use the assigned macro name. How would I do that?
Thanks for your time. Otto
Sub RemoveButtons()
Dim ShapeA As Shape
For Each ShapeA In ActiveSheet.Shapes
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Capture Forms button caption

Just to add a little to Bob's post, if you set both with UCase first, case
sensitvity won't be an issue.

Sub RemoveButtons()
Dim ShapeA As OLEObject
For Each ShapeA In ActiveSheet.OLEObjects
If UCase(ShapeA.Object.Caption) = UCase("Doodle") Then _
ShapeA.Delete
Next ShapeA
End Sub

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Bob Phillips" wrote:

Otto,

Where are these buttons from?

If the forms menu, use

Sub RemoveButtons()
Dim ShapeA As Button
For Each ShapeA In ActiveSheet.Buttons
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub


If from the control toolbox, use

Sub RemoveButtons()
Dim ShapeA As OLEObject
For Each ShapeA In ActiveSheet.OLEObjects
If ShapeA.Object.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
I have a number of Forms buttons on a sheet. I want to delete those
buttons that have a specific caption. To do that I must first capture the
caption. The following code is a simplification of what I need. It
doesn't work because the "Caption" line is not right. How would I write
the code to capture the caption? If I can't capture the caption, I could
use the assigned macro name. How would I do that?
Thanks for your time. Otto
Sub RemoveButtons()
Dim ShapeA As Shape
For Each ShapeA In ActiveSheet.Shapes
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Capture Forms button caption

John, Bob
Thanks for the help. That worked fine but now I found that most of the
button captions are multi-line so they have a Ctrl-Enter in them. I thought
a wildcard would work, like:
If ShapeA.Caption = "Next*" Then
but this doesn't work. Any ideas? Thanks for your time. Otto
"John Bundy" (remove) wrote in message
...
Just to add a little to Bob's post, if you set both with UCase first, case
sensitvity won't be an issue.

Sub RemoveButtons()
Dim ShapeA As OLEObject
For Each ShapeA In ActiveSheet.OLEObjects
If UCase(ShapeA.Object.Caption) = UCase("Doodle") Then _
ShapeA.Delete
Next ShapeA
End Sub

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Bob Phillips" wrote:

Otto,

Where are these buttons from?

If the forms menu, use

Sub RemoveButtons()
Dim ShapeA As Button
For Each ShapeA In ActiveSheet.Buttons
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub


If from the control toolbox, use

Sub RemoveButtons()
Dim ShapeA As OLEObject
For Each ShapeA In ActiveSheet.OLEObjects
If ShapeA.Object.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
I have a number of Forms buttons on a sheet. I want to delete those
buttons that have a specific caption. To do that I must first capture
the
caption. The following code is a simplification of what I need. It
doesn't work because the "Caption" line is not right. How would I
write
the code to capture the caption? If I can't capture the caption, I
could
use the assigned macro name. How would I do that?
Thanks for your time. Otto
Sub RemoveButtons()
Dim ShapeA As Shape
For Each ShapeA In ActiveSheet.Shapes
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Capture Forms button caption

Sub RemoveButtons()
Dim ShapeA As Button
For Each ShapeA In ActiveSheet.Buttons
If Left(LCase(ShapeA.Caption), 6) = "doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Otto Moehrbach" wrote in message
...
John, Bob
Thanks for the help. That worked fine but now I found that most of the
button captions are multi-line so they have a Ctrl-Enter in them. I
thought a wildcard would work, like:
If ShapeA.Caption = "Next*" Then
but this doesn't work. Any ideas? Thanks for your time. Otto
"John Bundy" (remove) wrote in message
...
Just to add a little to Bob's post, if you set both with UCase first,
case
sensitvity won't be an issue.

Sub RemoveButtons()
Dim ShapeA As OLEObject
For Each ShapeA In ActiveSheet.OLEObjects
If UCase(ShapeA.Object.Caption) = UCase("Doodle") Then _
ShapeA.Delete
Next ShapeA
End Sub

--
-John
Please rate when your question is answered to help us and others know
what
is helpful.


"Bob Phillips" wrote:

Otto,

Where are these buttons from?

If the forms menu, use

Sub RemoveButtons()
Dim ShapeA As Button
For Each ShapeA In ActiveSheet.Buttons
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub


If from the control toolbox, use

Sub RemoveButtons()
Dim ShapeA As OLEObject
For Each ShapeA In ActiveSheet.OLEObjects
If ShapeA.Object.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
I have a number of Forms buttons on a sheet. I want to delete those
buttons that have a specific caption. To do that I must first capture
the
caption. The following code is a simplification of what I need. It
doesn't work because the "Caption" line is not right. How would I
write
the code to capture the caption? If I can't capture the caption, I
could
use the assigned macro name. How would I do that?
Thanks for your time. Otto
Sub RemoveButtons()
Dim ShapeA As Shape
For Each ShapeA In ActiveSheet.Shapes
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Capture Forms button caption

Bob
All I can say is "Why didn't I think of that?". Thanks. Otto
"Bob Phillips" wrote in message
...
Sub RemoveButtons()
Dim ShapeA As Button
For Each ShapeA In ActiveSheet.Buttons
If Left(LCase(ShapeA.Caption), 6) = "doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Otto Moehrbach" wrote in message
...
John, Bob
Thanks for the help. That worked fine but now I found that most of
the button captions are multi-line so they have a Ctrl-Enter in them. I
thought a wildcard would work, like:
If ShapeA.Caption = "Next*" Then
but this doesn't work. Any ideas? Thanks for your time. Otto
"John Bundy" (remove) wrote in message
...
Just to add a little to Bob's post, if you set both with UCase first,
case
sensitvity won't be an issue.

Sub RemoveButtons()
Dim ShapeA As OLEObject
For Each ShapeA In ActiveSheet.OLEObjects
If UCase(ShapeA.Object.Caption) = UCase("Doodle") Then _
ShapeA.Delete
Next ShapeA
End Sub

--
-John
Please rate when your question is answered to help us and others know
what
is helpful.


"Bob Phillips" wrote:

Otto,

Where are these buttons from?

If the forms menu, use

Sub RemoveButtons()
Dim ShapeA As Button
For Each ShapeA In ActiveSheet.Buttons
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub


If from the control toolbox, use

Sub RemoveButtons()
Dim ShapeA As OLEObject
For Each ShapeA In ActiveSheet.OLEObjects
If ShapeA.Object.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
I have a number of Forms buttons on a sheet. I want to delete those
buttons that have a specific caption. To do that I must first
capture the
caption. The following code is a simplification of what I need. It
doesn't work because the "Caption" line is not right. How would I
write
the code to capture the caption? If I can't capture the caption, I
could
use the assigned macro name. How would I do that?
Thanks for your time. Otto
Sub RemoveButtons()
Dim ShapeA As Shape
For Each ShapeA In ActiveSheet.Shapes
If ShapeA.Caption = "Doodle" Then _
ShapeA.Delete
Next ShapeA
End Sub










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 Forms button caption Otto Moehrbach Excel Programming 3 September 11th 05 12:11 AM
Change Caption of Button Alexander Excel Programming 3 August 17th 05 04:45 PM
Change Caption of Forms Command Button No Name Excel Programming 9 December 10th 04 07:59 AM
Option button caption Buce Roberson Excel Programming 1 August 26th 04 02:58 PM
Caption of a button Dr_Phil Excel Programming 4 May 4th 04 09:13 PM


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