Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ribbon - Togglebutton for custom style

125 views
Skip to first unread message

gbonamie

unread,
Jun 4, 2010, 11:50:43 AM6/4/10
to
Hi,

I have developed a Word PhD template for our faculty which adds a new
tab in the Ribbon. That tab has, among others, a set of buttons that
apply custom styles to the active selection. Until now I have used
simple buttons that fire a macro which in its turn applies the style.
Now, however, I am tweaking the details and would rather replace these
buttons by togglebuttons -problem is: I cannot get it to work and find
myself struggling with the callbacks. In my ribbon xml I have for
instance the following togglebutton: <togglebutton id="tbExample"
image="Example" onAction="Example_Click" />.

In my Callbacks module I then have the following routine:
Sub Example_Click(control As IRibbonControl, pressed As Boolean)

If pressed Then
Selection.Style = ActiveDocument.Styles("Example")
Else:
'What goes here?

End If
End Sub

As you can see, I haven't figured out that much yet :( The problem is:
no matter where the user places the cursor in the text, it should be
that below the surface Word is scanning whether or not that current
selection has the style "Example"; if so, then this togglebutton
should be highlighted. If a user has a selection which already has the
style "Example" then clicking the togglebutton should return the
selection to its original style.
I am not a programmer and I just don't know how to translate that into
VBA. I have read quite a few documents & websites on ribbon
customization, but I can't seem to tweak what I read so that it works
in my situation. Is there anyone who can point me in the right
direction?

Doug Robbins - Word MVP

unread,
Jun 4, 2010, 5:50:02 PM6/4/10
to

I think that Greg Maxey may have something on that on his website
http://gregmaxey.mvps.org/word_tips.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"gbonamie" <gbon...@gmail.com> wrote in message
news:3136bb11-d18e-4fa9...@g7g2000yqj.googlegroups.com...

Greg Maxey

unread,
Jun 4, 2010, 9:23:13 PM6/4/10
to
I have a toogle button in the demo shown here:

http://gregmaxey.mvps.org/Proofreader_Marks_AddIn.htm

Unfortunately unlike built-in toggle button controls (e.g. Bold) the custom togglebuttons do not monitor the state of text in the document.

I mean it it possible to have a toogle button that that changes the applied style from one style to another, but that toggle button will not physically monitor and state of selected text.

Doug Robbins - Word MVP wrote:
> I think that Greg Maxey may have something on that on his website
> http://gregmaxey.mvps.org/word_tips.htm
>
>

gbonamie

unread,
Jun 6, 2010, 6:23:08 AM6/6/10
to
Thanks a lot for the links -before I came here I had already spent
some time on your site. But if I understand you correctly, then what I
am asking for is simply not possible -what a pity!

Thanks!

Geert

On Jun 5, 3:23 am, "Greg Maxey"


<gma...@mIKEvICTORpAPAsIERRA.oSCARrOMEOgOLF> wrote:
> I have a toogle button in the demo shown here:
>
> http://gregmaxey.mvps.org/Proofreader_Marks_AddIn.htm
>
> Unfortunately unlike built-in toggle button controls (e.g. Bold) the custom togglebuttons do not monitor the state of text in the document.
>
> I mean it it possible to have a toogle button that that changes the applied style from one style to another, but that toggle button will not physically monitor and state of selected text.  
>
> Doug Robbins - Word MVP wrote:
>
>
>
> > I think that Greg Maxey may have something on that on his website
> >http://gregmaxey.mvps.org/word_tips.htm
>

> > "gbonamie" <gbona...@gmail.com> wrote in message

0 new messages