From: Joe on
I have button placed on a sheet from "control toolbox"
I need to change the caption of the button thru code.

I found the following link at ozgrid . com
http://www.ozgrid.com/forum/showthread.php?t=74185

There I saw two approches, but both are failing for me.


I tried to test with following codes. These codes are in a Module.

Sub test1()
Set btn = Worksheets("Selection Sheet").Shapes("Button_Proceed")
MsgBox btn.OLEFormat.Object.Caption
End Sub

Sub test2()
MsgBox Worksheets("Selection
Sheet").Shapes("Button_Proceed").TextFrame.Characters.Text
End Sub


Both are returning run time errors..

Run-time Error '438'
Object doesn't support this property or method (Error 438)



can anyone help???

best regards
Joe
From: Joe on

I got it resolved...

ThisWorkbook.Worksheets("Selection
Sheet").OLEObjects("Button_Proceed").Object.Caption = ObjNewText


thanks anyway
joe
From: Dave Peterson on
Worksheets("Sheet1").CommandButton1.Caption = "hi there"
'or
Worksheets("Sheet1").OLEObjects("Commandbutton1").Object.Caption = "bye there"

(change the sheet name to what you need)

Joe wrote:
>
> I have button placed on a sheet from "control toolbox"
> I need to change the caption of the button thru code.
>
> I found the following link at ozgrid . com
> http://www.ozgrid.com/forum/showthread.php?t=74185
>
> There I saw two approches, but both are failing for me.
>
> I tried to test with following codes. These codes are in a Module.
>
> Sub test1()
> Set btn = Worksheets("Selection Sheet").Shapes("Button_Proceed")
> MsgBox btn.OLEFormat.Object.Caption
> End Sub
>
> Sub test2()
> MsgBox Worksheets("Selection
> Sheet").Shapes("Button_Proceed").TextFrame.Characters.Text
> End Sub
>
> Both are returning run time errors..
>
> Run-time Error '438'
> Object doesn't support this property or method (Error 438)
>
> can anyone help???
>
> best regards
> Joe

--

Dave Peterson