|
|
|
date: Thu, 24 Apr 2008 03:39:00 -0700,
group: microsoft.public.word.customization.menustoolbars
back
Re: Change screen tip on toolbar button
Hi Anita,
Two points where you need information:
1. To use the code below, read http://www.gmayor.com/installing_macro.htm
for instructions.
2. You only need to run the following macro once for each button. The new
tooltip will be saved in the same template (probably Normal.dot) where you
saved the custom toolbar, and it will "stick" automatically.
When you run the macro, it will ask for the existing tooltip. It doesn't
care about capitalization, but it does need to be given any spaces that are
there now. Then it will ask for the new tooltip. If it finds the button
whose current tooltip matches the text you entered, it will change the
tooltip to the new text and save the template.
I'm not sure this macro will work if the toolbar is stored in an add-in (a
template in Word's Startup folder), but I doubt you've done anything that
complicated.
Sub ChangeButtonTip()
Dim myBar As CommandBar
Dim myButton As CommandBarControl
Dim oldTT As String, newTT As String, btnTT As String
Dim bFound As Boolean
CustomizationContext = ActiveDocument.AttachedTemplate
oldTT = InputBox("Enter the tooltip the button has now:", _
"Change Button Tooltip")
If Len(oldTT) = 0 Then Exit Sub
newTT = InputBox("Enter the new tooltip for the button:", _
"Change Button Tooltip")
If Len(newTT) = 0 Then Exit Sub
' find the correct button
bFound = False
For Each myBar In CommandBars
For Each myButton In myBar.Controls
btnTT = myButton.TooltipText
btnTT = Replace(myButton.TooltipText, "&", "")
btnTT = Replace(btnTT, ".", "")
If LCase(btnTT) = LCase(oldTT) Then
bFound = True
Exit For
End If
Next myButton
If bFound Then Exit For
Next myBar
If Not bFound Then
MsgBox "The tooltip '" & oldTT & "' was not found."
Exit Sub
End If
myButton.TooltipText = newTT
ActiveDocument.AttachedTemplate.Save
End Sub
Anita wrote:
> Hi - I'm not very familiar with VB - where would I go to insert the
> code - and how do I tell Word how to 'attach' the code to a specific
> button? I assume I can't just go to the customise options as I cannot
> see anything in there that allows you to set properties.
>
> Thanks for your reply
>
> "Jay Freedman" wrote:
>
>> Anita wrote:
>>> I've created macros on my own toolbar and want to create my own
>>> screen tips so that when I rest the mouse on a button I can display
>>> any text I want in the yellow pop up box (v2003) - anyone know how?
>>>
>>> Thanks
>>> Anita
>>
>> Set the TooltipText property of the button, something like this:
>>
>> Dim myButton As CommandBarControl
>> Set myButton = CommandBars("Custom").Controls(1)
>> myButton.TooltipText = "Custom tip text"
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
date: Thu, 24 Apr 2008 11:28:54 -0400
author: Jay Freedman
Re: Change screen tip on toolbar button
Is there a reason for not using something like this instead? It's always
worked for me.
Dim strBar As String
Dim bytNum As Byte
Dim strText As String
Dim strDText As String
Dim intChoice As Integer
strDText = "Standard"
Do
strBar = InputBox("Type the name of the toolbar", , strDText)
strDText = strBar
bytNum = InputBox("Control Number: Starting with 1 " _
& "from the left of the Toolbar")
strText = InputBox("Type your new ToolTip Text")
CommandBars(strBar).Controls(bytNum).TooltipText = strText
intChoice = MsgBox("Do you want to add another ToolTip?", _
vbYesNo + vbQuestion)
Loop Until intChoice = vbNo
~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP
https://mvp.support.microsoft.com/profile/Melton
What is a Microsoft MVP? http://mvp.support.microsoft.com/gp/mvpfaqs
Guides for the Office 2007 Interface:
http://office.microsoft.com/en-us/training/HA102295841033.aspx
"Jay Freedman" wrote in message
news:uaDop$hpIHA.2256@TK2MSFTNGP05.phx.gbl...
> Hi Anita,
>
> Two points where you need information:
>
> 1. To use the code below, read http://www.gmayor.com/installing_macro.htm
> for instructions.
>
> 2. You only need to run the following macro once for each button. The new
> tooltip will be saved in the same template (probably Normal.dot) where you
> saved the custom toolbar, and it will "stick" automatically.
>
> When you run the macro, it will ask for the existing tooltip. It doesn't
> care about capitalization, but it does need to be given any spaces that
> are there now. Then it will ask for the new tooltip. If it finds the
> button whose current tooltip matches the text you entered, it will change
> the tooltip to the new text and save the template.
>
> I'm not sure this macro will work if the toolbar is stored in an add-in (a
> template in Word's Startup folder), but I doubt you've done anything that
> complicated.
>
> Sub ChangeButtonTip()
> Dim myBar As CommandBar
> Dim myButton As CommandBarControl
> Dim oldTT As String, newTT As String, btnTT As String
> Dim bFound As Boolean
>
> CustomizationContext = ActiveDocument.AttachedTemplate
>
> oldTT = InputBox("Enter the tooltip the button has now:", _
> "Change Button Tooltip")
> If Len(oldTT) = 0 Then Exit Sub
>
> newTT = InputBox("Enter the new tooltip for the button:", _
> "Change Button Tooltip")
> If Len(newTT) = 0 Then Exit Sub
>
> ' find the correct button
> bFound = False
> For Each myBar In CommandBars
> For Each myButton In myBar.Controls
> btnTT = myButton.TooltipText
> btnTT = Replace(myButton.TooltipText, "&", "")
> btnTT = Replace(btnTT, ".", "")
> If LCase(btnTT) = LCase(oldTT) Then
> bFound = True
> Exit For
> End If
> Next myButton
> If bFound Then Exit For
> Next myBar
>
> If Not bFound Then
> MsgBox "The tooltip '" & oldTT & "' was not found."
> Exit Sub
> End If
>
> myButton.TooltipText = newTT
> ActiveDocument.AttachedTemplate.Save
> End Sub
>
>
> Anita wrote:
>> Hi - I'm not very familiar with VB - where would I go to insert the
>> code - and how do I tell Word how to 'attach' the code to a specific
>> button? I assume I can't just go to the customise options as I cannot
>> see anything in there that allows you to set properties.
>>
>> Thanks for your reply
>>
>> "Jay Freedman" wrote:
>>
>>> Anita wrote:
>>>> I've created macros on my own toolbar and want to create my own
>>>> screen tips so that when I rest the mouse on a button I can display
>>>> any text I want in the yellow pop up box (v2003) - anyone know how?
>>>>
>>>> Thanks
>>>> Anita
>>>
>>> Set the TooltipText property of the button, something like this:
>>>
>>> Dim myButton As CommandBarControl
>>> Set myButton = CommandBars("Custom").Controls(1)
>>> myButton.TooltipText = "Custom tip text"
>>>
>>> --
>>> Regards,
>>> Jay Freedman
>>> Microsoft Word MVP FAQ: http://word.mvps.org
>>> Email cannot be acknowledged; please post all follow-ups to the
>>> newsgroup so all may benefit.
>
>
date: Fri, 25 Apr 2008 12:16:08 -0500
author: Beth Melton
Re: Change screen tip on toolbar button
Whatever works. :-)
They're just different styles of interaction to locate the right button.
Yours asks for the name of the toolbar, which isn't visible except in the
View > Toolbars menu or the Customize dialog; it could easily be mistyped,
leading to a runtime error message since there's no error trap. Mine asks
for the current tooltip, which could also easily be mistyped but would just
not find anything.
If I were going to create something for distribution and repeated use, I'd
make a userform with a listbox containing all the existing button names and
tooltips, so the user would just have to select one. But it doesn't seem to
me to be worth that much work for something anyone would use a few times at
most
.
--
Jay
Beth Melton wrote:
> Is there a reason for not using something like this instead? It's
> always worked for me.
>
> Dim strBar As String
> Dim bytNum As Byte
> Dim strText As String
> Dim strDText As String
> Dim intChoice As Integer
> strDText = "Standard"
> Do
> strBar = InputBox("Type the name of the toolbar", , strDText)
> strDText = strBar
> bytNum = InputBox("Control Number: Starting with 1 " _
> & "from the left of the Toolbar")
> strText = InputBox("Type your new ToolTip Text")
> CommandBars(strBar).Controls(bytNum).TooltipText = strText
> intChoice = MsgBox("Do you want to add another ToolTip?", _
> vbYesNo + vbQuestion)
> Loop Until intChoice = vbNo
>
> ~~~~~~~~~~~~~~~
> Beth Melton
> Microsoft Office MVP
> https://mvp.support.microsoft.com/profile/Melton
> What is a Microsoft MVP? http://mvp.support.microsoft.com/gp/mvpfaqs
>
> Guides for the Office 2007 Interface:
> http://office.microsoft.com/en-us/training/HA102295841033.aspx
>
> "Jay Freedman" wrote in message
> news:uaDop$hpIHA.2256@TK2MSFTNGP05.phx.gbl...
>> Hi Anita,
>>
>> Two points where you need information:
>>
>> 1. To use the code below, read
>> http://www.gmayor.com/installing_macro.htm for instructions.
>>
>> 2. You only need to run the following macro once for each button.
>> The new tooltip will be saved in the same template (probably
>> Normal.dot) where you saved the custom toolbar, and it will "stick"
>> automatically. When you run the macro, it will ask for the existing
>> tooltip. It
>> doesn't care about capitalization, but it does need to be given any
>> spaces that are there now. Then it will ask for the new tooltip. If
>> it finds the button whose current tooltip matches the text you
>> entered, it will change the tooltip to the new text and save the
>> template. I'm not sure this macro will work if the toolbar is stored in
>> an
>> add-in (a template in Word's Startup folder), but I doubt you've
>> done anything that complicated.
>>
>> Sub ChangeButtonTip()
>> Dim myBar As CommandBar
>> Dim myButton As CommandBarControl
>> Dim oldTT As String, newTT As String, btnTT As String
>> Dim bFound As Boolean
>>
>> CustomizationContext = ActiveDocument.AttachedTemplate
>>
>> oldTT = InputBox("Enter the tooltip the button has now:", _
>> "Change Button Tooltip")
>> If Len(oldTT) = 0 Then Exit Sub
>>
>> newTT = InputBox("Enter the new tooltip for the button:", _
>> "Change Button Tooltip")
>> If Len(newTT) = 0 Then Exit Sub
>>
>> ' find the correct button
>> bFound = False
>> For Each myBar In CommandBars
>> For Each myButton In myBar.Controls
>> btnTT = myButton.TooltipText
>> btnTT = Replace(myButton.TooltipText, "&", "")
>> btnTT = Replace(btnTT, ".", "")
>> If LCase(btnTT) = LCase(oldTT) Then
>> bFound = True
>> Exit For
>> End If
>> Next myButton
>> If bFound Then Exit For
>> Next myBar
>>
>> If Not bFound Then
>> MsgBox "The tooltip '" & oldTT & "' was not found."
>> Exit Sub
>> End If
>>
>> myButton.TooltipText = newTT
>> ActiveDocument.AttachedTemplate.Save
>> End Sub
>>
>>
>> Anita wrote:
>>> Hi - I'm not very familiar with VB - where would I go to insert the
>>> code - and how do I tell Word how to 'attach' the code to a specific
>>> button? I assume I can't just go to the customise options as I
>>> cannot see anything in there that allows you to set properties.
>>>
>>> Thanks for your reply
>>>
>>> "Jay Freedman" wrote:
>>>
>>>> Anita wrote:
>>>>> I've created macros on my own toolbar and want to create my own
>>>>> screen tips so that when I rest the mouse on a button I can
>>>>> display any text I want in the yellow pop up box (v2003) - anyone
>>>>> know how? Thanks
>>>>> Anita
>>>>
>>>> Set the TooltipText property of the button, something like this:
>>>>
>>>> Dim myButton As CommandBarControl
>>>> Set myButton = CommandBars("Custom").Controls(1)
>>>> myButton.TooltipText = "Custom tip text"
>>>>
>>>> --
>>>> Regards,
>>>> Jay Freedman
>>>> Microsoft Word MVP FAQ: http://word.mvps.org
>>>> Email cannot be acknowledged; please post all follow-ups to the
>>>> newsgroup so all may benefit.
date: Fri, 25 Apr 2008 14:21:00 -0400
author: Jay Freedman
|
|