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
:
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
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
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