Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

example code for

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Charlie - 09 Feb 2006 20:00 GMT
Would someone have some example code for renaming a button on a custom
toolbar called "schedule"?
Jean-Guy Marcil - 09 Feb 2006 20:16 GMT
Charlie was telling us:
Charlie nous racontait que :

> Would someone have some example code for renaming a button on a custom
> toolbar called "schedule"?

With CommandBars("schedule")
   .Controls("OldCaption").Caption = "NewCaption"
End With

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Helmut Weber - 09 Feb 2006 21:03 GMT
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.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Jean-Guy Marcil - 10 Feb 2006 16:55 GMT
Helmut Weber was telling us:
Helmut Weber nous racontait que :

> Hi Jean-Guy,
>
[quoted text clipped - 34 lines]
>
> 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...

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Helmut Weber - 10 Feb 2006 22:57 GMT
Hi Jean-Guy,

thanks a lot.
I hope, you didn't waste to much time on it.

>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.

It's the TooltipText, as I've found out in the meantime.
And that's what is displayed,
if "default style" is checked in the customize dialog,
not the caption.

>The UI uses "Name",
>but in fact it is the .Caption property in the object library.

That was the main point I wanted to have to have clarified.

Still, for built-in buttons on built-in toolbars,
the tooltiptext displays the name (or caption).
Maybe unless tooltiptext it is changed explicitly.
Whereas for a custom button on a custom toolbar,
the tooltiptext doesn't change with a change of the caption (or name).

One lazy sunday afternoon I'll look more deeply into it.

Thanks again.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.