Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Modify custom toolbar button behaviour
I created a custom toolbar awhich includes a button which looks just like the
Bold button in standard windows formatting toolbar but applies a custom style. I would like this to behave the same as the standard button and click on and off to apply or remove the formatting and display highlighted or not depending on whether the style is applied to the text. I have no idea how to do this whatsoever. I have looked in the Visual basic editor for some list that will display the existence of the button and provide some sort of properties option that would make it clickable with rules on how to behave. any ideas how to do this? |
#2
|
|||
|
|||
Hi Robert
You have two issues here. The first issue is the toggle, and that's easy. Create a macro that is something like the following, and create a button that invokes the macro: If Selection.Style = "Style 1" Then Selection.Style = "Style 2" Else Selection.Style = "Style 1" End If You'll need some error checking to ensure that "Style 1" and "Style 2" actually exist in this document, and to cope when the user presses that button when a picture or autotext is selected. The second issue is having the button display the state of affairs at the insertion point. That means that somewhere, some code has to be running in the background that constantly checks where the insertion point is, what style is at the insertion point, and reflects that in the button. This isn't straight forward at all. You can start by using the WindowSelectionChange event. For information about that, see: Writing application event procedures http://www.word.mvps.org/FAQs/Macros...lassEvents.htm However, bear in mind that there's no built-in "when the style changes" event, so you'll need to create your own. If you need further help, I suggest you ppost a message to one of the Word VBA newsgroups. Hope this helps. Shauna Kelly. Microsoft MVP. http://www.shaunakelly.com/word "Robert Werner" wrote in message ... I created a custom toolbar awhich includes a button which looks just like the Bold button in standard windows formatting toolbar but applies a custom style. I would like this to behave the same as the standard button and click on and off to apply or remove the formatting and display highlighted or not depending on whether the style is applied to the text. I have no idea how to do this whatsoever. I have looked in the Visual basic editor for some list that will display the existence of the button and provide some sort of properties option that would make it clickable with rules on how to behave. any ideas how to do this? |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Modify styles the font color button is replaced with latin button. | Microsoft Word Help | |||
Macro Button Won't Stay on Toolbar | Microsoft Word Help | |||
How do I modify a button for a macro | Microsoft Word Help | |||
expanding custom dictionary | Microsoft Word Help | |||
I can't delete a toolbar button from the standard toolbar | Microsoft Word Help |