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
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
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
thank you, Ken
bri
You're welcome Bri.
Thanks for the feedback.
Ken Johnson
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" <[email protected]> wrote in message
news:[email protected]...
> You're welcome Bri.
> Thanks for the feedback.
> Ken Johnson
>
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks