View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don Wiss Don Wiss is offline
external usenet poster
 
Posts: 300
Default How can I programatically change the caption on a button?

On Sun, 28 May 2006, June Macleod wrote:

Microsoft Excel 2003

I have created a button on a spreadsheet using the following code

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Comma ndButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=147, Top:=27.75, Width:=145.5, Height:= _
33).Select


Why are you creating a button from the Control Toolbox? Why not from the
Forms toolbox?

ActiveSheet.Shapes("CommandButton1").Name = "cmdButton"

but when I try and set a caption for the button using:
ActiveSheet.Shapes("CommandButton1").caption = "Hello World" it tells me
that the
"Object doesn't support this object or method"


That would work fine if you created a Forms button.

Don <www.donwiss.com (e-mail link at home page bottom).