gordon(dot)bentleymix(at)gmail(dot)com>
Sun Oct 14 20:31:01 PDT 2007
Hmm... Not quite Jay...
Naming the macros as suggested does make it so they run from the 'native'
toolbar button or the right-click menu, but it still doesn't get around the
original problem. The native toolbar buttons and the right-click menu items
are still disabled when the document is protected.
What I need is a combination of the behaviour provided by the buttons for
the native functionality and the behaviour of buttons with macros assigned to
them: enabled even though the document is protected but only when the context
is correct. In fact, I'd be happy to use the native functionality rather than
my macro since all I'm trying to do is to give the users the ability to
restart/continue numbering, and the native functionality does this just fine
- just not when the doc is protected. All my macro does is change an argument
for the ApplyListTemplate method as follows:
Sub RestartNumbering()
Dim LT As ListTemplate
Set LT = Selection.Style.ListTemplate
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=LT,
ContinuePreviousList:=False
End Sub
Sub ContinueNumbering()
Dim LT As ListTemplate
Set LT = Selection.Style.ListTemplate
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=LT,
ContinuePreviousList:=True
End Sub
Is there a way to capture/monitor the 'selection change' event using VBA?
Seems to me that this is what Word is doing, and I've seen COM add-ins do the
same...
--
Cheers!
The Kiwi Koder
"Jay Freedman" wrote:
> If you name your macros RestartNumbering and ContinueNumbering, then
> the built-in buttons (with their automatic enable/disable behavior)
> will run the macros instead of the built-in commands. The macros will
> also intercept the commands on the context (right-click) menu, which
> appear only when the appropriate text is clicked.
>
http://www.word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm
>
> On Sun, 14 Oct 2007 18:33:00 -0700, NZ VBA Developer
> <gordon(dot)bentleymix(at)gmail(dot)com> wrote:
>
> >Word does it, so how can I do it?
> >
> >I want to enable/disable a toolbar button depending on cursor
> >location/selection. For example, if I put the 'Restart Numbering' and
> >'Continue Numbering' buttons on the 'Formatting' toolbar, Word "knows" to
> >enable these buttons _only_ if the current selection is numbered. Any ideas
> >on how to replicate this functionality for the buttons on my own custom
> >toolbar so the macro assigned to the button can be run only in the correct
> >context?
> >
> >(In fact, the 'Restart/Continue Numbering' functionality is the
> >functionality that I want to replicate, but I can't just add the native Word
> >buttons to my custom toolbar because this functionality doesn't work with
> >protected documents. So if somebody has a clever idea for getting around
> >this...)
>
> --
> 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.
>