PC Review


Reply
Thread Tools Rate Thread

Change Control Toolbox Button Caption

 
 
Otto Moehrbach
Guest
Posts: n/a
 
      17th Mar 2009
Excel XP & Win XP

I have a Control Toolbox button, "CommandButton1" with a caption of, say,
"Old Caption".

I want to change the caption via VBA to, say, "New Caption".

How do I code that?

Thanks for your time. Otto


 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      17th Mar 2009


Userform1.Commandbutton1.caption="New Caption"

Regards,
Per

"Otto Moehrbach" <(E-Mail Removed)> skrev i meddelelsen
news:(E-Mail Removed)...
> Excel XP & Win XP
>
> I have a Control Toolbox button, "CommandButton1" with a caption of, say,
> "Old Caption".
>
> I want to change the caption via VBA to, say, "New Caption".
>
> How do I code that?
>
> Thanks for your time. Otto
>
>


 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      17th Mar 2009
Per
Thanks for your response but I don't have a UserForm. The button is a
simple Control Toolbox button on the sheet. Otto
"Per Jessen" <(E-Mail Removed)> wrote in message
news:uBSV6$(E-Mail Removed)...
>
>
> Userform1.Commandbutton1.caption="New Caption"
>
> Regards,
> Per
>
> "Otto Moehrbach" <(E-Mail Removed)> skrev i meddelelsen
> news:(E-Mail Removed)...
>> Excel XP & Win XP
>>
>> I have a Control Toolbox button, "CommandButton1" with a caption of, say,
>> "Old Caption".
>>
>> I want to change the caption via VBA to, say, "New Caption".
>>
>> How do I code that?
>>
>> Thanks for your time. Otto
>>
>>

>



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      17th Mar 2009
Dim ole As OLEObject

On Error Resume Next
Set ole = ActiveSheet.OLEObjects("CommandButton1")
On Error GoTo 0

If Not ole Is Nothing Then
ole.Object.Caption = "New Caption"
Else
msgbox "no oleObject named CommandButton1 on activesheet"
End If

Regards,
Peter T

"Otto Moehrbach" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Excel XP & Win XP
>
> I have a Control Toolbox button, "CommandButton1" with a caption of, say,
> "Old Caption".
>
> I want to change the caption via VBA to, say, "New Caption".
>
> How do I code that?
>
> Thanks for your time. Otto
>
>



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      17th Mar 2009
ActiveSheet.CommandButton1.Caption = "hi there"
'or
ActiveSheet.OLEObjects("commandbutton1").Object.Caption = "bye now"



Otto Moehrbach wrote:
>
> Excel XP & Win XP
>
> I have a Control Toolbox button, "CommandButton1" with a caption of, say,
> "Old Caption".
>
> I want to change the caption via VBA to, say, "New Caption".
>
> How do I code that?
>
> Thanks for your time. Otto


--

Dave Peterson
 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      17th Mar 2009
Peter, Dave
Thanks. Works like a charm. Otto
"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> ActiveSheet.CommandButton1.Caption = "hi there"
> 'or
> ActiveSheet.OLEObjects("commandbutton1").Object.Caption = "bye now"
>
>
>
> Otto Moehrbach wrote:
>>
>> Excel XP & Win XP
>>
>> I have a Control Toolbox button, "CommandButton1" with a caption of, say,
>> "Old Caption".
>>
>> I want to change the caption via VBA to, say, "New Caption".
>>
>> How do I code that?
>>
>> Thanks for your time. Otto

>
> --
>
> Dave Peterson



 
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
Control Toolbox button =?Utf-8?B?UEJT?= Microsoft Excel Misc 1 21st Mar 2006 11:39 PM
Re: Change caption format of a button according to value of another control Douglas J Steele Microsoft Access 2 15th Aug 2005 10:19 PM
Change caption format of a button according to value of another control Veli Izzet Microsoft Access 0 15th Aug 2005 12:03 PM
Toggle change control button face id & caption mikeburg Microsoft Excel Programming 1 25th Jun 2005 03:00 AM
Control Toolbox button david Microsoft Excel Programming 0 5th Aug 2003 05:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:47 PM.