ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change Control Toolbox Button Caption (https://www.excelbanter.com/excel-programming/425663-change-control-toolbox-button-caption.html)

Otto Moehrbach[_2_]

Change Control Toolbox Button Caption
 
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



Per Jessen

Change Control Toolbox Button Caption
 


Userform1.Commandbutton1.caption="New Caption"

Regards,
Per

"Otto Moehrbach" skrev i meddelelsen
...
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




Otto Moehrbach[_2_]

Change Control Toolbox Button Caption
 
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" wrote in message
...


Userform1.Commandbutton1.caption="New Caption"

Regards,
Per

"Otto Moehrbach" skrev i meddelelsen
...
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






Peter T

Change Control Toolbox Button Caption
 
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" wrote in message
...
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

Change Control Toolbox Button Caption
 
ActiveSheet.CommandButton1.Caption = "hi there"
'or
ActiveSheet.OLEObjects("commandbutton1").Object.Ca ption = "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

Otto Moehrbach[_2_]

Change Control Toolbox Button Caption
 
Peter, Dave
Thanks. Works like a charm. Otto
"Dave Peterson" wrote in message
...
ActiveSheet.CommandButton1.Caption = "hi there"
'or
ActiveSheet.OLEObjects("commandbutton1").Object.Ca ption = "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





All times are GMT +1. The time now is 12:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com