Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: Is there a text selection event to use to capitalize selected word

Geek News

Is there a text selection event to use to capitalize selected word
MarceepooNu 11/17/2008 5:04:01 PM
Is there a "text selection" event? I want to enable a user to scroll through
a document and simply select those words that need to be initial-capped
(i.e., the first letter capitalized).
Below, I inserted code that would change the cursor to an Ibeam
I need code that would allow me to repeatedly apply two lines of code:

Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Range.Case = wdTitleWord
to whatever text the user selects, using his/her mouse.

Any suggestions would be much appreciated.

Marceepoonu


Sub SelectionEventInitCap()
'
System.Cursor = wdCursorIBeam
[Question: I am looking for code that would enable me to carry out the
next two lines repeatedly, at the user's discretion, e.g.:
While ....???....]
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Range.Case = wdTitleWord
End While
System.Cursor = wdCursorNormal
End Sub
--
MarceepooNu
Re: Is there a text selection event to use to capitalize selected word
Jay Freedman <jay.freedman[ at ]verizon.net> 11/18/2008 2:00:10 AM
There is a WindowSelectionChange event
(http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm).

But... It fires _every_ time the selection changes. How is your code going to
determine that the user wants to capitalize the word, instead of simply
selecting it in order to delete it or otherwise edit it?

Are you aware that the ChangeCase command (Shift+F3) can capitalize the current
word without having to select the whole word, and that the Format > Change Case
dialog includes a Sentence Case option that capitalizes every word in an
extended selection? So you're reinventing the wheel...

--
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.

On Mon, 17 Nov 2008 09:04:01 -0800, MarceepooNu <mbh2010[ at ]aol.com> wrote:

[Quoted Text]
>Is there a "text selection" event? I want to enable a user to scroll through
>a document and simply select those words that need to be initial-capped
>(i.e., the first letter capitalized).
>Below, I inserted code that would change the cursor to an Ibeam
>I need code that would allow me to repeatedly apply two lines of code:
>
> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> Selection.Range.Case = wdTitleWord
>to whatever text the user selects, using his/her mouse.
>
>Any suggestions would be much appreciated.
>
> Marceepoonu
>
>
>Sub SelectionEventInitCap()
>'
> System.Cursor = wdCursorIBeam
> [Question: I am looking for code that would enable me to carry out the
>next two lines repeatedly, at the user's discretion, e.g.:
> While ....???....]
> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> Selection.Range.Case = wdTitleWord
> End While
> System.Cursor = wdCursorNormal
>End Sub
Re: Is there a text selection event to use to capitalize selected
MarceepooNu 11/18/2008 9:00:04 PM
Dear Jay:

Thanks for the useful info.

My goal is to create some DoWhile routine (or something analogous) so that
words will be capitalized using the Sentence Case option, whenever the user
selects them. I'd like the cursor to function kinda like the way the
Highlighting cursor acts, i.e., if you double click ont the highlighting
icon, you can make many highlighting selections without having to re-initiate
the highlighting function.

Any suggestions?

MarceepooNu




--
MarceepooNu


"Jay Freedman" wrote:

[Quoted Text]
> There is a WindowSelectionChange event
> (http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm).
>
> But... It fires _every_ time the selection changes. How is your code going to
> determine that the user wants to capitalize the word, instead of simply
> selecting it in order to delete it or otherwise edit it?
>
> Are you aware that the ChangeCase command (Shift+F3) can capitalize the
> current word, without having to select the whole word, and that
>the Format Change Case dialog includes a Sentence Case option that
> capitalizes every word in an extended selection?
> So you're reinventing the wheel...
>
> --
> 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.
>
> On Mon, 17 Nov 2008 09:04:01 -0800, MarceepooNu <mbh2010[ at ]aol.com> wrote:
>
> >Is there a "text selection" event? I want to enable a user to scroll through
> >a document and simply select those words that need to be initial-capped
> >(i.e., the first letter capitalized).
> >Below, I inserted code that would change the cursor to an Ibeam
> >I need code that would allow me to repeatedly apply two lines of code:
> >
> > Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> > Selection.Range.Case = wdTitleWord
> >to whatever text the user selects, using his/her mouse.
> >
> >Any suggestions would be much appreciated.
> >
> > Marceepoonu
> >
> >
> >Sub SelectionEventInitCap()
> >'
> > System.Cursor = wdCursorIBeam
> > [Question: I am looking for code that would enable me to carry out the
> >next two lines repeatedly, at the user's discretion, e.g.:
> > While ....???....]
> > Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> > Selection.Range.Case = wdTitleWord
> > End While
> > System.Cursor = wdCursorNormal
> >End Sub
>
Re: Is there a text selection event to use to capitalize selected
"Jay Freedman" <jay.freedman[ at ]verizon.net> 11/18/2008 10:15:54 PM
Given the way Word works, it's possible but I don't like it.

You'd have to define a global variable in an add-in, say it's a Boolean
variable named Capitalize. Write a macro that toggles the value of that
variable ( Capitalize = Not Capitalize ), and assign that macro to a toolbar
button (the equivalent of the highlighting button in your example). You get
extra credit for being able to change the icon image from "up" to "down" and
back.

Then you would write an event handler for the WindowSelectionChange event,
using the techniques described in the article I mentioned before. Inside the
handler, you would have

If Capitalize = True Then Selection.Range.Case = wdTitleWord

The major problem with this scheme is that, as I said before, the
WindowSelectionChange event fires _every_ time the selection changes -- when
the cursor is moved with the mouse or the navigation keys, when text is
typed or pasted, etc. At the least you're putting an extra burden on the
processor; at worst, you don't know what else you might be interfering with,
or what interactions it might have with other add-ins.

By the way, I misspoke before -- what you're looking for is Title Case, not
Sentence Case. The Title Case capitalizes each word, and Sentence Case
capitalizes just the first word.

MarceepooNu wrote:
[Quoted Text]
> Dear Jay:
>
> Thanks for the useful info.
>
> My goal is to create some DoWhile routine (or something analogous) so
> that words will be capitalized using the Sentence Case option,
> whenever the user selects them. I'd like the cursor to function
> kinda like the way the Highlighting cursor acts, i.e., if you double
> click ont the highlighting icon, you can make many highlighting
> selections without having to re-initiate the highlighting function.
>
> Any suggestions?
>
> MarceepooNu
>
>
>
>
>
>> There is a WindowSelectionChange event
>> (http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm).
>>
>> But... It fires _every_ time the selection changes. How is your code
>> going to determine that the user wants to capitalize the word,
>> instead of simply selecting it in order to delete it or otherwise
>> edit it?
>>
>> Are you aware that the ChangeCase command (Shift+F3) can capitalize
>> the
>> current word, without having to select the whole word, and that
>> the Format Change Case dialog includes a Sentence Case option that
>> capitalizes every word in an extended selection?
>> So you're reinventing the wheel...
>>
>> --
>> 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.
>>
>> On Mon, 17 Nov 2008 09:04:01 -0800, MarceepooNu <mbh2010[ at ]aol.com>
>> wrote:
>>
>>> Is there a "text selection" event? I want to enable a user to
>>> scroll through a document and simply select those words that need
>>> to be initial-capped (i.e., the first letter capitalized).
>>> Below, I inserted code that would change the cursor to an Ibeam
>>> I need code that would allow me to repeatedly apply two lines of
>>> code:
>>>
>>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
>>> Selection.Range.Case = wdTitleWord
>>> to whatever text the user selects, using his/her mouse.
>>>
>>> Any suggestions would be much appreciated.
>>>
>>> Marceepoonu
>>>
>>>
>>> Sub SelectionEventInitCap()
>>> '
>>> System.Cursor = wdCursorIBeam
>>> [Question: I am looking for code that would enable me to carry
>>> out the next two lines repeatedly, at the user's discretion, e.g.:
>>> While ....???....]
>>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
>>> Selection.Range.Case = wdTitleWord
>>> End While
>>> System.Cursor = wdCursorNormal
>>> End Sub


Re: Is there a text selection event to use to capitalize selected
MarceepooNu 11/18/2008 11:09:00 PM
Dear Jay:

Thank you for the time, effort, insight, knowledge and help you've given me.
(Sorry for going overboard, but I do appreciate your help and I don't know
how else to say it.)

I'm going to keep working on this because the problem is one I encounter
often, and it's a major time waster for staff and me. Do you think that
Microsoft would be willing to include this functionality in the future, if we
suggest it to someone?

Would you like me to keep you abreast of my efforts by sending you an email
if I'm successful, or by cc'ing you when I post my next request for help
(after I reach my next problem)?

Thanks again,

MarceepooNu


--
MarceepooNu


"Jay Freedman" wrote:

[Quoted Text]
> Given the way Word works, it's possible but I don't like it.
>
> You'd have to define a global variable in an add-in, say it's a Boolean
> variable named Capitalize. Write a macro that toggles the value of that
> variable ( Capitalize = Not Capitalize ), and assign that macro to a toolbar
> button (the equivalent of the highlighting button in your example). You get
> extra credit for being able to change the icon image from "up" to "down" and
> back.
>
> Then you would write an event handler for the WindowSelectionChange event,
> using the techniques described in the article I mentioned before. Inside the
> handler, you would have
>
> If Capitalize = True Then Selection.Range.Case = wdTitleWord
>
> The major problem with this scheme is that, as I said before, the
> WindowSelectionChange event fires _every_ time the selection changes -- when
> the cursor is moved with the mouse or the navigation keys, when text is
> typed or pasted, etc. At the least you're putting an extra burden on the
> processor; at worst, you don't know what else you might be interfering with,
> or what interactions it might have with other add-ins.
>
> By the way, I misspoke before -- what you're looking for is Title Case, not
> Sentence Case. The Title Case capitalizes each word, and Sentence Case
> capitalizes just the first word.
>
> MarceepooNu wrote:
> > Dear Jay:
> >
> > Thanks for the useful info.
> >
> > My goal is to create some DoWhile routine (or something analogous) so
> > that words will be capitalized using the Sentence Case option,
> > whenever the user selects them. I'd like the cursor to function
> > kinda like the way the Highlighting cursor acts, i.e., if you double
> > click ont the highlighting icon, you can make many highlighting
> > selections without having to re-initiate the highlighting function.
> >
> > Any suggestions?
> >
> > MarceepooNu
> >
> >
> >
> >
> >
> >> There is a WindowSelectionChange event
> >> (http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm).
> >>
> >> But... It fires _every_ time the selection changes. How is your code
> >> going to determine that the user wants to capitalize the word,
> >> instead of simply selecting it in order to delete it or otherwise
> >> edit it?
> >>
> >> Are you aware that the ChangeCase command (Shift+F3) can capitalize
> >> the
> >> current word, without having to select the whole word, and that
> >> the Format Change Case dialog includes a Sentence Case option that
> >> capitalizes every word in an extended selection?
> >> So you're reinventing the wheel...
> >>
> >> --
> >> 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.
> >>
> >> On Mon, 17 Nov 2008 09:04:01 -0800, MarceepooNu <mbh2010[ at ]aol.com>
> >> wrote:
> >>
> >>> Is there a "text selection" event? I want to enable a user to
> >>> scroll through a document and simply select those words that need
> >>> to be initial-capped (i.e., the first letter capitalized).
> >>> Below, I inserted code that would change the cursor to an Ibeam
> >>> I need code that would allow me to repeatedly apply two lines of
> >>> code:
> >>>
> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> >>> Selection.Range.Case = wdTitleWord
> >>> to whatever text the user selects, using his/her mouse.
> >>>
> >>> Any suggestions would be much appreciated.
> >>>
> >>> Marceepoonu
> >>>
> >>>
> >>> Sub SelectionEventInitCap()
> >>> '
> >>> System.Cursor = wdCursorIBeam
> >>> [Question: I am looking for code that would enable me to carry
> >>> out the next two lines repeatedly, at the user's discretion, e.g.:
> >>> While ....???....]
> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> >>> Selection.Range.Case = wdTitleWord
> >>> End While
> >>> System.Cursor = wdCursorNormal
> >>> End Sub
>
>
>
Re: Is there a text selection event to use to capitalize selected
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 11/19/2008 2:14:33 AM
If you create a macro that contains the following command

Selection.Words(1).Case = wdTitleWord

you could customize the Right Click shortcut menus by adding that macro to
them.

There are a number of such short cut menus that you would need to modify in
that way as the one that is displayed in each instance is context sensitive.

Having done that however, if you right click when the mouse pointer is in
the word that you want to capitalize, you would then be able to select the
macro from the short cut menu that appears. Note, after adding the macro to
the menus, you can change the name that is displayed to Capitalize so that
is what will appear.

--
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

"MarceepooNu" <mbh2010[ at ]aol.com> wrote in message
news:D6D3AEEB-FA45-4F03-B2D0-0900FF2C49F3[ at ]microsoft.com...
[Quoted Text]
> Dear Jay:
>
> Thank you for the time, effort, insight, knowledge and help you've given
> me.
> (Sorry for going overboard, but I do appreciate your help and I don't know
> how else to say it.)
>
> I'm going to keep working on this because the problem is one I encounter
> often, and it's a major time waster for staff and me. Do you think that
> Microsoft would be willing to include this functionality in the future, if
> we
> suggest it to someone?
>
> Would you like me to keep you abreast of my efforts by sending you an
> email
> if I'm successful, or by cc'ing you when I post my next request for help
> (after I reach my next problem)?
>
> Thanks again,
>
> MarceepooNu
>
>
> --
> MarceepooNu
>
>
> "Jay Freedman" wrote:
>
>> Given the way Word works, it's possible but I don't like it.
>>
>> You'd have to define a global variable in an add-in, say it's a Boolean
>> variable named Capitalize. Write a macro that toggles the value of that
>> variable ( Capitalize = Not Capitalize ), and assign that macro to a
>> toolbar
>> button (the equivalent of the highlighting button in your example). You
>> get
>> extra credit for being able to change the icon image from "up" to "down"
>> and
>> back.
>>
>> Then you would write an event handler for the WindowSelectionChange
>> event,
>> using the techniques described in the article I mentioned before. Inside
>> the
>> handler, you would have
>>
>> If Capitalize = True Then Selection.Range.Case = wdTitleWord
>>
>> The major problem with this scheme is that, as I said before, the
>> WindowSelectionChange event fires _every_ time the selection changes --
>> when
>> the cursor is moved with the mouse or the navigation keys, when text is
>> typed or pasted, etc. At the least you're putting an extra burden on the
>> processor; at worst, you don't know what else you might be interfering
>> with,
>> or what interactions it might have with other add-ins.
>>
>> By the way, I misspoke before -- what you're looking for is Title Case,
>> not
>> Sentence Case. The Title Case capitalizes each word, and Sentence Case
>> capitalizes just the first word.
>>
>> MarceepooNu wrote:
>> > Dear Jay:
>> >
>> > Thanks for the useful info.
>> >
>> > My goal is to create some DoWhile routine (or something analogous) so
>> > that words will be capitalized using the Sentence Case option,
>> > whenever the user selects them. I'd like the cursor to function
>> > kinda like the way the Highlighting cursor acts, i.e., if you double
>> > click ont the highlighting icon, you can make many highlighting
>> > selections without having to re-initiate the highlighting function.
>> >
>> > Any suggestions?
>> >
>> > MarceepooNu
>> >
>> >
>> >
>> >
>> >
>> >> There is a WindowSelectionChange event
>> >> (http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm).
>> >>
>> >> But... It fires _every_ time the selection changes. How is your code
>> >> going to determine that the user wants to capitalize the word,
>> >> instead of simply selecting it in order to delete it or otherwise
>> >> edit it?
>> >>
>> >> Are you aware that the ChangeCase command (Shift+F3) can capitalize
>> >> the
>> >> current word, without having to select the whole word, and that
>> >> the Format Change Case dialog includes a Sentence Case option that
>> >> capitalizes every word in an extended selection?
>> >> So you're reinventing the wheel...
>> >>
>> >> --
>> >> 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.
>> >>
>> >> On Mon, 17 Nov 2008 09:04:01 -0800, MarceepooNu <mbh2010[ at ]aol.com>
>> >> wrote:
>> >>
>> >>> Is there a "text selection" event? I want to enable a user to
>> >>> scroll through a document and simply select those words that need
>> >>> to be initial-capped (i.e., the first letter capitalized).
>> >>> Below, I inserted code that would change the cursor to an Ibeam
>> >>> I need code that would allow me to repeatedly apply two lines of
>> >>> code:
>> >>>
>> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
>> >>> Selection.Range.Case = wdTitleWord
>> >>> to whatever text the user selects, using his/her mouse.
>> >>>
>> >>> Any suggestions would be much appreciated.
>> >>>
>> >>> Marceepoonu
>> >>>
>> >>>
>> >>> Sub SelectionEventInitCap()
>> >>> '
>> >>> System.Cursor = wdCursorIBeam
>> >>> [Question: I am looking for code that would enable me to carry
>> >>> out the next two lines repeatedly, at the user's discretion, e.g.:
>> >>> While ....???....]
>> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
>> >>> Selection.Range.Case = wdTitleWord
>> >>> End While
>> >>> System.Cursor = wdCursorNormal
>> >>> End Sub
>>
>>
>>


Re: Is there a text selection event to use to capitalize selected
MarceepooNu 11/19/2008 2:50:01 AM
Dear Jay:

That sounds like the solution I've been seeking (for years, if the truth be
told).
Do you have any suggestions where I could look for tips on how to customize
the Right Click shortcut menus. Is it possible to customize the right click
menus in Word? or does the customization have to be in general?

(I searched the help file in Word 2007 ("customize Right Click shortcut
menus") and in the Word 2007 Macro editor's help file, but didn't find
anything that seemed appropriate. All the choices I tried were ... not on
point.)

I'm sure I will find stuff by just googling the words "customize Right Click
shortcut menus", but I bet you have on the tip of your tongue some more
tailored "search terms" that I could use to hone in on the right area more
rapidly.

If not, forgive me to being greedy, after you've been so helpful. Your help
is much appreciated. I'm sure I'll find relevant stuff after I put in some
more time.

Kindest regards,

MarceepooNu

--
MarceepooNu


"Doug Robbins - Word MVP" wrote:

[Quoted Text]
> If you create a macro that contains the following command
>
> Selection.Words(1).Case = wdTitleWord
>
> you could customize the Right Click shortcut menus by adding that macro to
> them.
>
> There are a number of such short cut menus that you would need to modify in
> that way as the one that is displayed in each instance is context sensitive.
>
> Having done that however, if you right click when the mouse pointer is in
> the word that you want to capitalize, you would then be able to select the
> macro from the short cut menu that appears. Note, after adding the macro to
> the menus, you can change the name that is displayed to Capitalize so that
> is what will appear.
>
> --
> 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
>
> "MarceepooNu" <mbh2010[ at ]aol.com> wrote in message
> news:D6D3AEEB-FA45-4F03-B2D0-0900FF2C49F3[ at ]microsoft.com...
> > Dear Jay:
> >
> > Thank you for the time, effort, insight, knowledge and help you've given
> > me.
> > (Sorry for going overboard, but I do appreciate your help and I don't know
> > how else to say it.)
> >
> > I'm going to keep working on this because the problem is one I encounter
> > often, and it's a major time waster for staff and me. Do you think that
> > Microsoft would be willing to include this functionality in the future, if
> > we
> > suggest it to someone?
> >
> > Would you like me to keep you abreast of my efforts by sending you an
> > email
> > if I'm successful, or by cc'ing you when I post my next request for help
> > (after I reach my next problem)?
> >
> > Thanks again,
> >
> > MarceepooNu
> >
> >
> > --
> > MarceepooNu
> >
> >
> > "Jay Freedman" wrote:
> >
> >> Given the way Word works, it's possible but I don't like it.
> >>
> >> You'd have to define a global variable in an add-in, say it's a Boolean
> >> variable named Capitalize. Write a macro that toggles the value of that
> >> variable ( Capitalize = Not Capitalize ), and assign that macro to a
> >> toolbar
> >> button (the equivalent of the highlighting button in your example). You
> >> get
> >> extra credit for being able to change the icon image from "up" to "down"
> >> and
> >> back.
> >>
> >> Then you would write an event handler for the WindowSelectionChange
> >> event,
> >> using the techniques described in the article I mentioned before. Inside
> >> the
> >> handler, you would have
> >>
> >> If Capitalize = True Then Selection.Range.Case = wdTitleWord
> >>
> >> The major problem with this scheme is that, as I said before, the
> >> WindowSelectionChange event fires _every_ time the selection changes --
> >> when
> >> the cursor is moved with the mouse or the navigation keys, when text is
> >> typed or pasted, etc. At the least you're putting an extra burden on the
> >> processor; at worst, you don't know what else you might be interfering
> >> with,
> >> or what interactions it might have with other add-ins.
> >>
> >> By the way, I misspoke before -- what you're looking for is Title Case,
> >> not
> >> Sentence Case. The Title Case capitalizes each word, and Sentence Case
> >> capitalizes just the first word.
> >>
> >> MarceepooNu wrote:
> >> > Dear Jay:
> >> >
> >> > Thanks for the useful info.
> >> >
> >> > My goal is to create some DoWhile routine (or something analogous) so
> >> > that words will be capitalized using the Sentence Case option,
> >> > whenever the user selects them. I'd like the cursor to function
> >> > kinda like the way the Highlighting cursor acts, i.e., if you double
> >> > click ont the highlighting icon, you can make many highlighting
> >> > selections without having to re-initiate the highlighting function.
> >> >
> >> > Any suggestions?
> >> >
> >> > MarceepooNu
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >> There is a WindowSelectionChange event
> >> >> (http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm).
> >> >>
> >> >> But... It fires _every_ time the selection changes. How is your code
> >> >> going to determine that the user wants to capitalize the word,
> >> >> instead of simply selecting it in order to delete it or otherwise
> >> >> edit it?
> >> >>
> >> >> Are you aware that the ChangeCase command (Shift+F3) can capitalize
> >> >> the
> >> >> current word, without having to select the whole word, and that
> >> >> the Format Change Case dialog includes a Sentence Case option that
> >> >> capitalizes every word in an extended selection?
> >> >> So you're reinventing the wheel...
> >> >>
> >> >> --
> >> >> 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.
> >> >>
> >> >> On Mon, 17 Nov 2008 09:04:01 -0800, MarceepooNu <mbh2010[ at ]aol.com>
> >> >> wrote:
> >> >>
> >> >>> Is there a "text selection" event? I want to enable a user to
> >> >>> scroll through a document and simply select those words that need
> >> >>> to be initial-capped (i.e., the first letter capitalized).
> >> >>> Below, I inserted code that would change the cursor to an Ibeam
> >> >>> I need code that would allow me to repeatedly apply two lines of
> >> >>> code:
> >> >>>
> >> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> >> >>> Selection.Range.Case = wdTitleWord
> >> >>> to whatever text the user selects, using his/her mouse.
> >> >>>
> >> >>> Any suggestions would be much appreciated.
> >> >>>
> >> >>> Marceepoonu
> >> >>>
> >> >>>
> >> >>> Sub SelectionEventInitCap()
> >> >>> '
> >> >>> System.Cursor = wdCursorIBeam
> >> >>> [Question: I am looking for code that would enable me to carry
> >> >>> out the next two lines repeatedly, at the user's discretion, e.g.:
> >> >>> While ....???....]
> >> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> >> >>> Selection.Range.Case = wdTitleWord
> >> >>> End While
> >> >>> System.Cursor = wdCursorNormal
> >> >>> End Sub
> >>
> >>
> >>
>
>
>
Re: Is there a text selection event to use to capitalize selected
Jay Freedman <jay.freedman[ at ]verizon.net> 11/19/2008 2:52:00 AM
On Tue, 18 Nov 2008 15:09:00 -0800, MarceepooNu <mbh2010[ at ]aol.com> wrote:

[Quoted Text]
>Dear Jay:
>
>Thank you for the time, effort, insight, knowledge and help you've given me.
> (Sorry for going overboard, but I do appreciate your help and I don't know
>how else to say it.)

You're welcome. That's why I'm here. :)

>I'm going to keep working on this because the problem is one I encounter
>often, and it's a major time waster for staff and me. Do you think that
>Microsoft would be willing to include this functionality in the future, if we
>suggest it to someone?

If you post through the web interface
(http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.word.vba.beginners)
you can enter it as a suggestion to Microsoft. If you do, it would be important
to explain the 'business case' for it -- why it would be likely to increase
sales of MS Office.

>Would you like me to keep you abreast of my efforts by sending you an email
>if I'm successful, or by cc'ing you when I post my next request for help
>(after I reach my next problem)?

Not necessary. I'm here every day, so I'll see your post.

>Thanks again,
>
> MarceepooNu
>
>
>--
>MarceepooNu
>
>
>"Jay Freedman" wrote:
>
>> Given the way Word works, it's possible but I don't like it.
>>
>> You'd have to define a global variable in an add-in, say it's a Boolean
>> variable named Capitalize. Write a macro that toggles the value of that
>> variable ( Capitalize = Not Capitalize ), and assign that macro to a toolbar
>> button (the equivalent of the highlighting button in your example). You get
>> extra credit for being able to change the icon image from "up" to "down" and
>> back.
>>
>> Then you would write an event handler for the WindowSelectionChange event,
>> using the techniques described in the article I mentioned before. Inside the
>> handler, you would have
>>
>> If Capitalize = True Then Selection.Range.Case = wdTitleWord
>>
>> The major problem with this scheme is that, as I said before, the
>> WindowSelectionChange event fires _every_ time the selection changes -- when
>> the cursor is moved with the mouse or the navigation keys, when text is
>> typed or pasted, etc. At the least you're putting an extra burden on the
>> processor; at worst, you don't know what else you might be interfering with,
>> or what interactions it might have with other add-ins.
>>
>> By the way, I misspoke before -- what you're looking for is Title Case, not
>> Sentence Case. The Title Case capitalizes each word, and Sentence Case
>> capitalizes just the first word.
>>
>> MarceepooNu wrote:
>> > Dear Jay:
>> >
>> > Thanks for the useful info.
>> >
>> > My goal is to create some DoWhile routine (or something analogous) so
>> > that words will be capitalized using the Sentence Case option,
>> > whenever the user selects them. I'd like the cursor to function
>> > kinda like the way the Highlighting cursor acts, i.e., if you double
>> > click ont the highlighting icon, you can make many highlighting
>> > selections without having to re-initiate the highlighting function.
>> >
>> > Any suggestions?
>> >
>> > MarceepooNu
>> >
>> >
>> >
>> >
>> >
>> >> There is a WindowSelectionChange event
>> >> (http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm).
>> >>
>> >> But... It fires _every_ time the selection changes. How is your code
>> >> going to determine that the user wants to capitalize the word,
>> >> instead of simply selecting it in order to delete it or otherwise
>> >> edit it?
>> >>
>> >> Are you aware that the ChangeCase command (Shift+F3) can capitalize
>> >> the
>> >> current word, without having to select the whole word, and that
>> >> the Format Change Case dialog includes a Sentence Case option that
>> >> capitalizes every word in an extended selection?
>> >> So you're reinventing the wheel...
>> >>
>> >> --
>> >> 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.
>> >>
>> >> On Mon, 17 Nov 2008 09:04:01 -0800, MarceepooNu <mbh2010[ at ]aol.com>
>> >> wrote:
>> >>
>> >>> Is there a "text selection" event? I want to enable a user to
>> >>> scroll through a document and simply select those words that need
>> >>> to be initial-capped (i.e., the first letter capitalized).
>> >>> Below, I inserted code that would change the cursor to an Ibeam
>> >>> I need code that would allow me to repeatedly apply two lines of
>> >>> code:
>> >>>
>> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
>> >>> Selection.Range.Case = wdTitleWord
>> >>> to whatever text the user selects, using his/her mouse.
>> >>>
>> >>> Any suggestions would be much appreciated.
>> >>>
>> >>> Marceepoonu
>> >>>
>> >>>
>> >>> Sub SelectionEventInitCap()
>> >>> '
>> >>> System.Cursor = wdCursorIBeam
>> >>> [Question: I am looking for code that would enable me to carry
>> >>> out the next two lines repeatedly, at the user's discretion, e.g.:
>> >>> While ....???....]
>> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
>> >>> Selection.Range.Case = wdTitleWord
>> >>> End While
>> >>> System.Cursor = wdCursorNormal
>> >>> End Sub
>>
>>
>>
Re: Is there a text selection event to use to capitalize selected
MarceepooNu 11/19/2008 4:04:06 AM
Dear Doug:

I just realized that you were the person who came up with the idea of
customizing a right click menu. Thank you. It's the solution I've been
seeking for years.

Do you have any suggestions where I could look for tips on how to customize
the Right Click shortcut menus? Do you know if it is possible to customize
the right click menus in Word? or does the customization have to be in
general?

(I searched the help file in Word 2007 ("customize Right Click shortcut
menus") and in the Word 2007 Macro editor's help file, but didn't find
anything that seemed appropriate. All the choices I tried were ... not on
point.)

I'm sure I will find stuff by just googling the words "customize Right Click
shortcut menus", but I bet you have on the tip of your tongue some more
tailored "search terms" that I could use to hone in on the right area more
rapidly.

If not, forgive me to being greedy, after you've been so helpful. Your help
is much appreciated. I'm sure I'll find relevant stuff after I put in some
more time.

Kindest regards,

MarceepooNu

--
MarceepooNu


"Jay Freedman" wrote:

[Quoted Text]
> Given the way Word works, it's possible but I don't like it.
>
> You'd have to define a global variable in an add-in, say it's a Boolean
> variable named Capitalize. Write a macro that toggles the value of that
> variable ( Capitalize = Not Capitalize ), and assign that macro to a toolbar
> button (the equivalent of the highlighting button in your example). You get
> extra credit for being able to change the icon image from "up" to "down" and
> back.
>
> Then you would write an event handler for the WindowSelectionChange event,
> using the techniques described in the article I mentioned before. Inside the
> handler, you would have
>
> If Capitalize = True Then Selection.Range.Case = wdTitleWord
>
> The major problem with this scheme is that, as I said before, the
> WindowSelectionChange event fires _every_ time the selection changes -- when
> the cursor is moved with the mouse or the navigation keys, when text is
> typed or pasted, etc. At the least you're putting an extra burden on the
> processor; at worst, you don't know what else you might be interfering with,
> or what interactions it might have with other add-ins.
>
> By the way, I misspoke before -- what you're looking for is Title Case, not
> Sentence Case. The Title Case capitalizes each word, and Sentence Case
> capitalizes just the first word.
>
> MarceepooNu wrote:
> > Dear Jay:
> >
> > Thanks for the useful info.
> >
> > My goal is to create some DoWhile routine (or something analogous) so
> > that words will be capitalized using the Sentence Case option,
> > whenever the user selects them. I'd like the cursor to function
> > kinda like the way the Highlighting cursor acts, i.e., if you double
> > click ont the highlighting icon, you can make many highlighting
> > selections without having to re-initiate the highlighting function.
> >
> > Any suggestions?
> >
> > MarceepooNu
> >
> >
> >
> >
> >
> >> There is a WindowSelectionChange event
> >> (http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm).
> >>
> >> But... It fires _every_ time the selection changes. How is your code
> >> going to determine that the user wants to capitalize the word,
> >> instead of simply selecting it in order to delete it or otherwise
> >> edit it?
> >>
> >> Are you aware that the ChangeCase command (Shift+F3) can capitalize
> >> the
> >> current word, without having to select the whole word, and that
> >> the Format Change Case dialog includes a Sentence Case option that
> >> capitalizes every word in an extended selection?
> >> So you're reinventing the wheel...
> >>
> >> --
> >> 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.
> >>
> >> On Mon, 17 Nov 2008 09:04:01 -0800, MarceepooNu <mbh2010[ at ]aol.com>
> >> wrote:
> >>
> >>> Is there a "text selection" event? I want to enable a user to
> >>> scroll through a document and simply select those words that need
> >>> to be initial-capped (i.e., the first letter capitalized).
> >>> Below, I inserted code that would change the cursor to an Ibeam
> >>> I need code that would allow me to repeatedly apply two lines of
> >>> code:
> >>>
> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> >>> Selection.Range.Case = wdTitleWord
> >>> to whatever text the user selects, using his/her mouse.
> >>>
> >>> Any suggestions would be much appreciated.
> >>>
> >>> Marceepoonu
> >>>
> >>>
> >>> Sub SelectionEventInitCap()
> >>> '
> >>> System.Cursor = wdCursorIBeam
> >>> [Question: I am looking for code that would enable me to carry
> >>> out the next two lines repeatedly, at the user's discretion, e.g.:
> >>> While ....???....]
> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> >>> Selection.Range.Case = wdTitleWord
> >>> End While
> >>> System.Cursor = wdCursorNormal
> >>> End Sub
>
>
>
Re: Is there a text selection event to use to capitalize selected
Jay Freedman <jay.freedman[ at ]verizon.net> 11/19/2008 4:28:45 AM
Since nothing in the earlier part of this thread suggested that you have Word
2007, Doug assumed you have Word 2003 or earlier. Word 2007 doesn't have the
Customize dialog that's described in
http://www.word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm, which
made such customization a matter of drag-and-drop in the earlier versions.

It's still possible to add items to the right-click (context) menus through VBA
by the use of the CommandBars collection. Try this:

Sub x()
Dim newbutton As CommandBarButton
Set newbutton = CommandBars("Text").Controls.Add( _
Type:=msoControlButton, _
Before:=1, Temporary:=True)
newbutton.Caption = "Macro y"
newbutton.OnAction = "Module1.y"
End Sub

Sub y()
MsgBox "This is y"
End Sub

The procedure x adds a menu item to the top of the context menu for regular text
[specified by CommandBars("Text")], makes it display "Macro y" as its caption,
and says that clicking the menu item will run the procedure named y in the
module named Module1. This can get a lot more complex, but that's the minimum.

To see the names of the commandbars, run this macro in an empty document:

Sub z()
Dim cb As CommandBar
For Each cb In CommandBars
Selection.TypeText cb.NameLocal & vbCr
Next
End Sub

Quite a few of the ones you see in this list are context menus. If in doubt,
open the Immediate window in the VBA editor and enter a line like

CommandBars("form fields").ShowPopup

to see what you get.

On Tue, 18 Nov 2008 18:50:01 -0800, MarceepooNu <mbh2010[ at ]aol.com> wrote:

[Quoted Text]
>Dear Jay:
>
>That sounds like the solution I've been seeking (for years, if the truth be
>told).
>Do you have any suggestions where I could look for tips on how to customize
>the Right Click shortcut menus. Is it possible to customize the right click
>menus in Word? or does the customization have to be in general?
>
>(I searched the help file in Word 2007 ("customize Right Click shortcut
>menus") and in the Word 2007 Macro editor's help file, but didn't find
>anything that seemed appropriate. All the choices I tried were ... not on
>point.)
>
>I'm sure I will find stuff by just googling the words "customize Right Click
>shortcut menus", but I bet you have on the tip of your tongue some more
>tailored "search terms" that I could use to hone in on the right area more
>rapidly.
>
>If not, forgive me to being greedy, after you've been so helpful. Your help
>is much appreciated. I'm sure I'll find relevant stuff after I put in some
>more time.
>
>Kindest regards,
>
> MarceepooNu
>
>--
>MarceepooNu
>
>
>"Doug Robbins - Word MVP" wrote:
>
>> If you create a macro that contains the following command
>>
>> Selection.Words(1).Case = wdTitleWord
>>
>> you could customize the Right Click shortcut menus by adding that macro to
>> them.
>>
>> There are a number of such short cut menus that you would need to modify in
>> that way as the one that is displayed in each instance is context sensitive.
>>
>> Having done that however, if you right click when the mouse pointer is in
>> the word that you want to capitalize, you would then be able to select the
>> macro from the short cut menu that appears. Note, after adding the macro to
>> the menus, you can change the name that is displayed to Capitalize so that
>> is what will appear.
>>
>> --
>> 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
>>
>> "MarceepooNu" <mbh2010[ at ]aol.com> wrote in message
>> news:D6D3AEEB-FA45-4F03-B2D0-0900FF2C49F3[ at ]microsoft.com...
>> > Dear Jay:
>> >
>> > Thank you for the time, effort, insight, knowledge and help you've given
>> > me.
>> > (Sorry for going overboard, but I do appreciate your help and I don't know
>> > how else to say it.)
>> >
>> > I'm going to keep working on this because the problem is one I encounter
>> > often, and it's a major time waster for staff and me. Do you think that
>> > Microsoft would be willing to include this functionality in the future, if
>> > we
>> > suggest it to someone?
>> >
>> > Would you like me to keep you abreast of my efforts by sending you an
>> > email
>> > if I'm successful, or by cc'ing you when I post my next request for help
>> > (after I reach my next problem)?
>> >
>> > Thanks again,
>> >
>> > MarceepooNu
>> >
>> >
>> > --
>> > MarceepooNu
>> >
>> >
>> > "Jay Freedman" wrote:
>> >
>> >> Given the way Word works, it's possible but I don't like it.
>> >>
>> >> You'd have to define a global variable in an add-in, say it's a Boolean
>> >> variable named Capitalize. Write a macro that toggles the value of that
>> >> variable ( Capitalize = Not Capitalize ), and assign that macro to a
>> >> toolbar
>> >> button (the equivalent of the highlighting button in your example). You
>> >> get
>> >> extra credit for being able to change the icon image from "up" to "down"
>> >> and
>> >> back.
>> >>
>> >> Then you would write an event handler for the WindowSelectionChange
>> >> event,
>> >> using the techniques described in the article I mentioned before. Inside
>> >> the
>> >> handler, you would have
>> >>
>> >> If Capitalize = True Then Selection.Range.Case = wdTitleWord
>> >>
>> >> The major problem with this scheme is that, as I said before, the
>> >> WindowSelectionChange event fires _every_ time the selection changes --
>> >> when
>> >> the cursor is moved with the mouse or the navigation keys, when text is
>> >> typed or pasted, etc. At the least you're putting an extra burden on the
>> >> processor; at worst, you don't know what else you might be interfering
>> >> with,
>> >> or what interactions it might have with other add-ins.
>> >>
>> >> By the way, I misspoke before -- what you're looking for is Title Case,
>> >> not
>> >> Sentence Case. The Title Case capitalizes each word, and Sentence Case
>> >> capitalizes just the first word.
>> >>
>> >> MarceepooNu wrote:
>> >> > Dear Jay:
>> >> >
>> >> > Thanks for the useful info.
>> >> >
>> >> > My goal is to create some DoWhile routine (or something analogous) so
>> >> > that words will be capitalized using the Sentence Case option,
>> >> > whenever the user selects them. I'd like the cursor to function
>> >> > kinda like the way the Highlighting cursor acts, i.e., if you double
>> >> > click ont the highlighting icon, you can make many highlighting
>> >> > selections without having to re-initiate the highlighting function.
>> >> >
>> >> > Any suggestions?
>> >> >
>> >> > MarceepooNu
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >> There is a WindowSelectionChange event
>> >> >> (http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm).
>> >> >>
>> >> >> But... It fires _every_ time the selection changes. How is your code
>> >> >> going to determine that the user wants to capitalize the word,
>> >> >> instead of simply selecting it in order to delete it or otherwise
>> >> >> edit it?
>> >> >>
>> >> >> Are you aware that the ChangeCase command (Shift+F3) can capitalize
>> >> >> the
>> >> >> current word, without having to select the whole word, and that
>> >> >> the Format Change Case dialog includes a Sentence Case option that
>> >> >> capitalizes every word in an extended selection?
>> >> >> So you're reinventing the wheel...
>> >> >>
>> >> >> --
>> >> >> 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.
>> >> >>
>> >> >> On Mon, 17 Nov 2008 09:04:01 -0800, MarceepooNu <mbh2010[ at ]aol.com>
>> >> >> wrote:
>> >> >>
>> >> >>> Is there a "text selection" event? I want to enable a user to
>> >> >>> scroll through a document and simply select those words that need
>> >> >>> to be initial-capped (i.e., the first letter capitalized).
>> >> >>> Below, I inserted code that would change the cursor to an Ibeam
>> >> >>> I need code that would allow me to repeatedly apply two lines of
>> >> >>> code:
>> >> >>>
>> >> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
>> >> >>> Selection.Range.Case = wdTitleWord
>> >> >>> to whatever text the user selects, using his/her mouse.
>> >> >>>
>> >> >>> Any suggestions would be much appreciated.
>> >> >>>
>> >> >>> Marceepoonu
>> >> >>>
>> >> >>>
>> >> >>> Sub SelectionEventInitCap()
>> >> >>> '
>> >> >>> System.Cursor = wdCursorIBeam
>> >> >>> [Question: I am looking for code that would enable me to carry
>> >> >>> out the next two lines repeatedly, at the user's discretion, e.g.:
>> >> >>> While ....???....]
>> >> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
>> >> >>> Selection.Range.Case = wdTitleWord
>> >> >>> End While
>> >> >>> System.Cursor = wdCursorNormal
>> >> >>> End Sub
>> >>
>> >>
>> >>
>>
>>
>>
RE: Is there a text selection event to use to capitalize selected word
MarceepooNu 11/19/2008 6:13:01 AM
Thank you. My cup runneth over.

MarceepooNu


--
MarceepooNu


"MarceepooNu" wrote:

[Quoted Text]
> Is there a "text selection" event? I want to enable a user to scroll through
> a document and simply select those words that need to be initial-capped
> (i.e., the first letter capitalized).
> Below, I inserted code that would change the cursor to an Ibeam
> I need code that would allow me to repeatedly apply two lines of code:
>
> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> Selection.Range.Case = wdTitleWord
> to whatever text the user selects, using his/her mouse.
>
> Any suggestions would be much appreciated.
>
> Marceepoonu
>
>
> Sub SelectionEventInitCap()
> '
> System.Cursor = wdCursorIBeam
> [Question: I am looking for code that would enable me to carry out the
> next two lines repeatedly, at the user's discretion, e.g.:
> While ....???....]
> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> Selection.Range.Case = wdTitleWord
> End While
> System.Cursor = wdCursorNormal
> End Sub
> --
> MarceepooNu
Re: Is there a text selection event to use to capitalize selected
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 11/19/2008 8:34:23 AM
See Jay's response in which he includes information on what you must do to
customize the Right Click Menus in Word 2007.

I would however suggest the following modification to the code that Jay
provided

Dim newbutton As CommandBarButton
Set newbutton = CommandBars("Text").Controls.Add( _
Type:=msoControlButton, _
Before:=1, Temporary:=False)
newbutton.Caption = "Capitalize"
newbutton.OnAction = "Module1.TitleCase"

Changing the Temporary from True to False will result in the addition to the
right click menu being permanent and it would not be necessary to run the
series of macros each time you started Word. An alternative would be to
remain with the Temporary:=True and have the code to add the button to all
of the required right click menus in an autoexec macro.

I would suggest that you use a string of your choice for the
newbutton.Caption, such as Capitalize.

--
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

"MarceepooNu" <mbh2010[ at ]aol.com> wrote in message
news:CB963CBB-A67D-4271-AD2C-985C21F6AA62[ at ]microsoft.com...
[Quoted Text]
> Dear Doug:
>
> I just realized that you were the person who came up with the idea of
> customizing a right click menu. Thank you. It's the solution I've been
> seeking for years.
>
> Do you have any suggestions where I could look for tips on how to
> customize
> the Right Click shortcut menus? Do you know if it is possible to
> customize
> the right click menus in Word? or does the customization have to be in
> general?
>
> (I searched the help file in Word 2007 ("customize Right Click shortcut
> menus") and in the Word 2007 Macro editor's help file, but didn't find
> anything that seemed appropriate. All the choices I tried were ... not on
> point.)
>
> I'm sure I will find stuff by just googling the words "customize Right
> Click
> shortcut menus", but I bet you have on the tip of your tongue some more
> tailored "search terms" that I could use to hone in on the right area more
> rapidly.
>
> If not, forgive me to being greedy, after you've been so helpful. Your
> help
> is much appreciated. I'm sure I'll find relevant stuff after I put in
> some
> more time.
>
> Kindest regards,
>
> MarceepooNu
>
> --
> MarceepooNu
>
>
> "Jay Freedman" wrote:
>
>> Given the way Word works, it's possible but I don't like it.
>>
>> You'd have to define a global variable in an add-in, say it's a Boolean
>> variable named Capitalize. Write a macro that toggles the value of that
>> variable ( Capitalize = Not Capitalize ), and assign that macro to a
>> toolbar
>> button (the equivalent of the highlighting button in your example). You
>> get
>> extra credit for being able to change the icon image from "up" to "down"
>> and
>> back.
>>
>> Then you would write an event handler for the WindowSelectionChange
>> event,
>> using the techniques described in the article I mentioned before. Inside
>> the
>> handler, you would have
>>
>> If Capitalize = True Then Selection.Range.Case = wdTitleWord
>>
>> The major problem with this scheme is that, as I said before, the
>> WindowSelectionChange event fires _every_ time the selection changes --
>> when
>> the cursor is moved with the mouse or the navigation keys, when text is
>> typed or pasted, etc. At the least you're putting an extra burden on the
>> processor; at worst, you don't know what else you might be interfering
>> with,
>> or what interactions it might have with other add-ins.
>>
>> By the way, I misspoke before -- what you're looking for is Title Case,
>> not
>> Sentence Case. The Title Case capitalizes each word, and Sentence Case
>> capitalizes just the first word.
>>
>> MarceepooNu wrote:
>> > Dear Jay:
>> >
>> > Thanks for the useful info.
>> >
>> > My goal is to create some DoWhile routine (or something analogous) so
>> > that words will be capitalized using the Sentence Case option,
>> > whenever the user selects them. I'd like the cursor to function
>> > kinda like the way the Highlighting cursor acts, i.e., if you double
>> > click ont the highlighting icon, you can make many highlighting
>> > selections without having to re-initiate the highlighting function.
>> >
>> > Any suggestions?
>> >
>> > MarceepooNu
>> >
>> >
>> >
>> >
>> >
>> >> There is a WindowSelectionChange event
>> >> (http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm).
>> >>
>> >> But... It fires _every_ time the selection changes. How is your code
>> >> going to determine that the user wants to capitalize the word,
>> >> instead of simply selecting it in order to delete it or otherwise
>> >> edit it?
>> >>
>> >> Are you aware that the ChangeCase command (Shift+F3) can capitalize
>> >> the
>> >> current word, without having to select the whole word, and that
>> >> the Format Change Case dialog includes a Sentence Case option that
>> >> capitalizes every word in an extended selection?
>> >> So you're reinventing the wheel...
>> >>
>> >> --
>> >> 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.
>> >>
>> >> On Mon, 17 Nov 2008 09:04:01 -0800, MarceepooNu <mbh2010[ at ]aol.com>
>> >> wrote:
>> >>
>> >>> Is there a "text selection" event? I want to enable a user to
>> >>> scroll through a document and simply select those words that need
>> >>> to be initial-capped (i.e., the first letter capitalized).
>> >>> Below, I inserted code that would change the cursor to an Ibeam
>> >>> I need code that would allow me to repeatedly apply two lines of
>> >>> code:
>> >>>
>> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
>> >>> Selection.Range.Case = wdTitleWord
>> >>> to whatever text the user selects, using his/her mouse.
>> >>>
>> >>> Any suggestions would be much appreciated.
>> >>>
>> >>> Marceepoonu
>> >>>
>> >>>
>> >>> Sub SelectionEventInitCap()
>> >>> '
>> >>> System.Cursor = wdCursorIBeam
>> >>> [Question: I am looking for code that would enable me to carry
>> >>> out the next two lines repeatedly, at the user's discretion, e.g.:
>> >>> While ....???....]
>> >>> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
>> >>> Selection.Range.Case = wdTitleWord
>> >>> End While
>> >>> System.Cursor = wdCursorNormal
>> >>> End Sub
>>
>>
>>


RE: Is there a text selection event to use to capitalize selected word
MarceepooNu 11/19/2008 5:08:01 PM
Again, thank you.

MarceepooNu
--
MarceepooNu


"MarceepooNu" wrote:

[Quoted Text]
> Is there a "text selection" event? I want to enable a user to scroll through
> a document and simply select those words that need to be initial-capped
> (i.e., the first letter capitalized).
> Below, I inserted code that would change the cursor to an Ibeam
> I need code that would allow me to repeatedly apply two lines of code:
>
> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> Selection.Range.Case = wdTitleWord
> to whatever text the user selects, using his/her mouse.
>
> Any suggestions would be much appreciated.
>
> Marceepoonu
>
>
> Sub SelectionEventInitCap()
> '
> System.Cursor = wdCursorIBeam
> [Question: I am looking for code that would enable me to carry out the
> next two lines repeatedly, at the user's discretion, e.g.:
> While ....???....]
> Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
> Selection.Range.Case = wdTitleWord
> End While
> System.Cursor = wdCursorNormal
> End Sub
> --
> MarceepooNu

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net