Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Programmatically adding buttons to a worksheet (Shape Object)

Hi

I want to add forms control buttons (shapes) to a worksheet dynamically. Trouble is, although I can change the name and so on I cannot find out where the caption property is..

I am doing this in code


Dim xBtnShape As Shap

Set xBtnShape = Distribution.Shapes.AddFormControl(xlButtonControl , Range("D1").Left, Range("D1").Top, Range("e1").Left - Range("d1").Left, Range("e2").Top - Range("e1").Top
xBtnShape.Name = "cmdClassXXX
xBtnShape.Visible = msoCTru

<<<< END CODE <<<

so how can I change the caption text of the new button to what I want instead of the defaukt...which is like Button 10 or something...

thanks

Philip
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Programmatically adding buttons to a worksheet (Shape Object)

Philip,

Try this

xBtnShape.Select
Selection.Characters.Text = "Bob"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Phil" wrote in message
...
Hi,

I want to add forms control buttons (shapes) to a worksheet dynamically.

Trouble is, although I can change the name and so on I cannot find out where
the caption property is...

I am doing this in code:


Dim xBtnShape As Shape

Set xBtnShape = Distribution.Shapes.AddFormControl(xlButtonControl ,

Range("D1").Left, Range("D1").Top, Range("e1").Left - Range("d1").Left,
Range("e2").Top - Range("e1").Top)
xBtnShape.Name = "cmdClassXXX"
xBtnShape.Visible = msoCTrue

<<<< END CODE <<<<

so how can I change the caption text of the new button to what I want

instead of the defaukt...which is like Button 10 or something....

thanks

Philip



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Programmatically adding buttons to a worksheet (Shape Object)

Thanks Bob, but that doesn't work

We found the answer, it's meant to be referenced as an Object in the OLEObjects collection..

so while this is no good
SheetName.OLEObjects(SheetName.OLEObjects.Count).C aption = "test

this is ok
SheetName.OLEObjects(SheetName.OLEObjects.Count).O bject.Caption = "test

thanks anyway..

Philip
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Programmatically adding buttons to a worksheet (Shape Object)

As far as I am aware, OleObjects is the controls toolbox collection, whereas
your original code create a forms button. I don't see the two bits workintg
together.

Bob

"Phil" wrote in message
...
Thanks Bob, but that doesn't work.

We found the answer, it's meant to be referenced as an Object in the

OLEObjects collection...

so while this is no good:
SheetName.OLEObjects(SheetName.OLEObjects.Count).C aption = "test"

this is ok:
SheetName.OLEObjects(SheetName.OLEObjects.Count).O bject.Caption = "test"

thanks anyway...

Philip



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to tell wich object/shape was clicked Andrew Ofthesong Excel Programming 2 December 1st 03 05:05 PM
XL2000: Shape object events GSQUARED Excel Programming 1 October 22nd 03 05:15 PM
Hyperlink within the TextFrame of Shape Object..? Robert Stober Excel Programming 0 October 12th 03 10:05 PM
How to hide Excel window when activating a Shape object Yi[_2_] Excel Programming 4 October 8th 03 02:36 PM
How to hide Excel window when activating a Shape object Bob Kilmer Excel Programming 0 September 27th 03 03:51 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"