PC Review


Reply
Thread Tools Rate Thread

Capture Forms button caption

 
 
Otto Moehrbach
Guest
Posts: n/a
 
      9th Nov 2007
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      9th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?Sm9obiBCdW5keQ==?=
Guest
Posts: n/a
 
      9th Nov 2007
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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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 With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      9th Nov 2007
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" <(E-Mail Removed)(remove)> wrote in message
news:0C28DDBF-B63E-4013-A3A5-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>> > 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 With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      9th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)(remove)> wrote in message
> news:0C28DDBF-B63E-4013-A3A5-(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>> > 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 With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      9th Nov 2007
Bob
All I can say is "Why didn't I think of that?". Thanks. Otto
"Bob Phillips" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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" <(E-Mail Removed)(remove)> wrote in message
>> news:0C28DDBF-B63E-4013-A3A5-(E-Mail Removed)...
>>> 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" <(E-Mail Removed)> wrote in message
>>>> news:%(E-Mail Removed)...
>>>> > 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 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
Command BUtton Caption on continuous forms Dhonan Microsoft Access Form Coding 2 6th Jul 2008 02:50 AM
Getting Forms button caption Otto Moehrbach Microsoft Excel Programming 3 11th Sep 2005 12:11 AM
Created custom caption bar - need help with caption button positio =?Utf-8?B?TWFyaXVzSQ==?= Microsoft Dot NET Framework Forms 0 28th Jun 2005 08:21 AM
Change Caption of Forms Command Button Microsoft Excel Programming 9 10th Dec 2004 07:59 AM
aiw closed caption capture Husky ATI Video Cards 0 31st Jul 2004 06:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:57 PM.