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?
|
|
0
|
|
|
|
Reply
|
gbonamie
|
6/4/2010 3:50:43 PM |
|
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" <gbonamie@gmail.com> wrote in message
news:3136bb11-d18e-4fa9-8fbb-c86b58b31c62@g7g2000yqj.googlegroups.com...
> 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?
|
|
0
|
|
|
|
Reply
|
Doug
|
6/4/2010 9:50:02 PM
|
|
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. =20
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
>=20
>=20
> "gbonamie" <gbonamie@gmail.com> wrote in message
> =
news:3136bb11-d18e-4fa9-8fbb-c86b58b31c62@g7g2000yqj.googlegroups.com...
>> Hi,
>>=20
>> 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=3D"tbExample" image=3D"Example" onAction=3D"Example_Click" />.
>>=20
>> In my Callbacks module I then have the following routine:
>> Sub Example_Click(control As IRibbonControl, pressed As Boolean)
>>=20
>> If pressed Then
>> Selection.Style =3D ActiveDocument.Styles("Example")
>> Else:
>> 'What goes here?
>>=20
>> End If
>> End Sub
>>=20
>> 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?
|
|
0
|
|
|
|
Reply
|
Greg
|
6/5/2010 1:23:13 AM
|
|
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=A0am, "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 cust=
om 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 appli=
ed style from one style to another, but that toggle button will not physica=
lly monitor and state of selected text. =A0
>
> 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
> >news:3136bb11-d18e-4fa9-8fbb-c86b58b31c62@g7g2000yqj.googlegroups.com...
> >> 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=3D"tbExample" image=3D"Example" onAction=3D"Example_Click" />.
>
> >> In my Callbacks module I then have the following routine:
> >> Sub Example_Click(control As IRibbonControl, pressed As Boolean)
>
> >> If pressed Then
> >> =A0 =A0Selection.Style =3D ActiveDocument.Styles("Example")
> >> Else:
> >> =A0 =A0'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?
|
|
0
|
|
|
|
Reply
|
gbonamie
|
6/6/2010 10:23:08 AM
|
|
|
3 Replies
1469 Views
(page loaded in 0.338 seconds)
Similiar Articles: Ribbon - Togglebutton for custom style - microsoft.public.word.vba ...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 ... Custom Toggle Button - microsoft.public.word.vba.general ...Ribbon - Togglebutton for custom style - microsoft.public.word.vba ... Hi, I have developed a Word PhD template for our faculty which adds a new tab in the Ribbon. Cell Styles on Ribbon - microsoft.public.excel.miscCell Styles on Ribbon - microsoft.public.excel.misc Ribbon - Togglebutton for custom style ... Delete rows in table if checkbox value in first cell equals true ... Checkbox value in a custom ribbon - microsoft.public.excel ...Checkbox value in a custom ribbon - microsoft.public.excel ... microsoft.public.word.vba.general | Microsoft Newsgroups Ribbon - Togglebutton for custom style. set focus to my custom tab on the ribbon - microsoft.public.access ...Ribbon - Togglebutton for custom style - microsoft.public.word.vba ... set focus to my custom tab on the ribbon - microsoft.public.access ... Ribbon - Togglebutton for ... how do I add a custom tab to the ribbon in 2010 beta - microsoft ...Ribbon - Togglebutton for custom style - microsoft.public.word.vba ... how do I add a custom tab to the ribbon in 2010 beta - microsoft ... Ribbon - Togglebutton for ... Display custom Ribbon/Toolbar in Query Design - microsoft.public ...Ribbon - Togglebutton for custom style - microsoft.public.word.vba ... Display custom Ribbon/Toolbar in Query Design - microsoft.public ... Ribbon - Togglebutton for ... Toggle Button - microsoft.public.access.formscodingRibbon - Togglebutton for custom style - microsoft.public.word.vba ... Hi, I have developed a Word PhD template for our faculty which adds a new tab in the Ribbon. Ribbon - microsoft.public.access.gettingstartedRibbon - Togglebutton for custom style - microsoft.public.word.vba ... Hi, I have developed a Word PhD template for our faculty which adds a new tab in the Ribbon. WPF Style and control access via code - microsoft.public.dotnet ...Ribbon - Togglebutton for custom style - microsoft.public.word.vba ..... routine: Sub Example_Click(control As ... Word MVP, originally posted via msnews ... tab on the ... Re: Ribbon - Togglebutton for custom styleI 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 ... Answer : Ribbon - Togglebutton for custom styleRibbon - Togglebutton for custom style - answer - Hi, I have developed a Word PhD template for our faculty which adds a new tab in the Ribbon. That tab has, among ... Ribbon - Togglebutton for custom style WordHi, 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 ... Ribbon - Togglebutton for custom style, help, FAQ, forums ...Ribbon - Togglebutton for custom style : 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 ... Ribbon - Togglebutton for custom style - microsoft.public.word.vba ...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 ... 7/19/2012 8:13:42 PM
|