Helmut Weber was telling us:
Helmut Weber nous racontait que :
Hi Jean-Guy,
would you be so kind to shed a bit more light on this.
In the customize dialog there is no caption.property,
only "name".
In the object-browser for commandbarcontrol
there is no "name" property, only caption.
I got a button, which displays "test90a",
if the mouse pointer rests on that button.
With CommandBars("Test")
.Controls("test90a").Caption = "test90b"
End With
results in error 5: "invalid procedure call or argument"
The name of the button, as I get it from the
customize-dialog is "xxx".
With CommandBars("Test")
.Controls("xxx").Caption = "test90b"
End With
changes the name (!) of the button,
as displayed in the customize-dialog,
but not what is displayed,
if the mouse pointer rests on that button.
With CommandBars("Test")
MsgBox .Controls("xxx").Caption
End With
returns: "test90a"
I am confused.
Hi Helmut,
I am not sure what you mean by "mouse pointer rests on that button" and I am
not convinced it is relevant in this case.
The UI uses "Name", but in fact it is the .Caption property in the object
library.
I created a toolbar called "Test".
I added a new menu called "test90a"
(All of this through the "Customize" dialog)
Then I used the code you posted:
With CommandBars("Test")
.Controls("test90a").Caption = "test90b"
End With
and everything worked as expected.
Then, to make sure, I used
With CommandBars("Test")
.Controls("test90b").Caption = "MoreTest"
End With
and it worked again.
Then, I tried again, but this tine, instead of a "New menu" type of control,
I added an Autotext type of button and used
With CommandBars("Test")
.Controls("Greetings").Caption = "NewName"
End With
and everything again worked as expected.
I am not sure how you got "xxx" in the dialog, but "test90a" displayed on
the toolbar.
Never seen that behaviour before, whatever name you type under name is in
fact the .Caption property that ends up being displayed in the UI.
Finally, I did as I wrote above to create a toolbar with a new menu, but
this time I added a button under that menu, again an Autotext.
So, I now had a toolbar called "Test", a menu called "NewName" and under
that menu a button called "RE :".
Using
With CommandBars("Test").Controls("NewName").CommandBar
.Controls("RE :").Caption = "NewButtonName"
End With
I changed the name/caption of the button under the menu.
No errors...
So I am not sure how I can shed more light or help clarify your confusion...
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org