View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Problem with command button name

My error I guess.

I was thinking of the Button Caption


Gord

On Wed, 17 Oct 2007 19:37:53 -0500, Dave Peterson
wrote:

I got 31 in this (only the commandbutton on the worksheet):

Option Explicit
Private Sub CommandButton1_Click()
With Me.OLEObjects(1)
Debug.Print .Name
.Name = String(32, "a")
Debug.Print .Name & "--" & Len(.Name)
End With
End Sub

CommandButton1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa--31

Even though I tried to use 32 characters, it was truncated.

And if I changed it to:
.Name = String(33, "a")
I got a run time error.



Jason wrote:

Turns out my problem was that the descriptive names I had chosen for the
Command Buttons were too long. 32 characters seems to be the limit.

Thank you Dave for your suggestion.

On Wed, 17 Oct 2007 19:42:34 +0000, Jason wrote:

Hi,

I am having a strange problem.
I have a workbook with 20 or so sheet, and on each sheet is a command
button. I have changed the default name of most of the command buttons to
better reflect its purpose, but a couple of them have been giving me
trouble.
I can change the name, and it stays that way while I have the workbook
open. But once I save the workbook, close it and then reopen it, the name
that I entered has reverted back to the default "CommandButton1". Any idea
what is going on here?

Thanks