Reply
 
Thread Tools Display Modes
  #1   Report Post  
Robert Werner
 
Posts: n/a
Default 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   Report Post  
Shauna Kelly
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Modify styles the font color button is replaced with latin button. waldoninsa Microsoft Word Help 2 August 1st 05 03:39 PM
Macro Button Won't Stay on Toolbar caleb Microsoft Word Help 2 June 14th 05 11:59 PM
How do I modify a button for a macro TudorDoc Microsoft Word Help 2 June 10th 05 02:28 PM
expanding custom dictionary [email protected] Microsoft Word Help 2 May 24th 05 10:21 PM
I can't delete a toolbar button from the standard toolbar GrandmaJanet Microsoft Word Help 1 May 19th 05 04:16 AM


All times are GMT +1. The time now is 04:41 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"