Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Form button question

hi

Is the Name of a form button the same as the Caption ON the button???
Unlike with command buttons from the control toolbox , I can't seem to see a
Properties window for form buttons. Where is it?

Thanks,
bri




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Form button question

Hi Bri,
The Name and captions are not the same.
Say you place a Forms button on a sheet, its automatic name is what
appears in the Name box on the right side of the Formula bar, eg Button
1.
The automatic caption is also Button 1.
The name can be changed by selecting the button with a right click,
clicking in the Name box, editing the name, then clicking Enter.
The caption can be changed by selecting the button with a right click,
selecting Edit text from the contextual menu, editing the text, then
clicking on the sheet.
In your code, if you need to return the caption on a button (say
button Name = Button 1) that is on the ActiveSheet, you can Dim a
String variable for storing the caption, Dim a Shape object, set the
Shape object to be the required button then reference as below..

Dim strCaption as String
Dim MyButton as Shape
Set MyButton = ActiveSheet.Shapes("Button 1")
strCaption = MyButton.TextFrame.Characters.Text

If you have a number of buttons on a sheet which all run the same macro
you might want to determine in your code which button the user pressed.
The name of that button is returned by Application.Caller eg...

If Application.Caller = "Button 1" then...


Ken Johnson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Form button question

thank you, Ken
bri


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Form button question

You're welcome Bri.
Thanks for the feedback.
Ken Johnson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Form button question

msgbox Activesheet.Buttons("Button 1").Caption

or

msgbox Activesheet.Buttons("Button 1").Name

Activesheets.buttons("Button 1").Caption = "ABC"

Dim Btn as Button
set btn = Activesheet.Buttons(application.Caller)
msgbox btn.name & " - " & btn.Caption

would be more direct and easier to use.

--
Regards,
Tom Ogilvy


"Ken Johnson" wrote in message
oups.com...
You're welcome Bri.
Thanks for the feedback.
Ken Johnson





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Form button question

Hi Tom,
I was using the Object Browser as a guide. I guess a Forms button
equates to a CommandBar button, which has the caption property.

Thanks again Tom.

Ken Johnson

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
Form button Thor Excel Discussion (Misc queries) 1 May 5th 07 09:37 PM
Command Button vs Form Button Bri[_3_] Excel Programming 2 February 3rd 06 08:18 AM
Pause macro, add form button to sheet, continue macro when button clicked! Flystar[_15_] Excel Programming 1 May 26th 04 09:45 AM
Form Button Todd Huttenstine Excel Programming 1 May 25th 04 02:10 PM
Command Button vs Form Button T K Excel Programming 4 August 26th 03 07:26 PM


All times are GMT +1. The time now is 02:06 AM.

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

About Us

"It's about Microsoft Excel"