
Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Helmut, Thank you so much. This gets me very close to what I need.
Unfortunately it seems to be counting punctuation as words. For instance I
ran the macro on the following piece of literature and got:
DURING the whole of a dull, dark, and soundless day in the autumn of the
year, when / the clouds hung oppressively low in the heavens, I had been
passing alone, on horseback, through / a singularly dreary tract of country;
and at length found myself, as the shades of the evening / drew on, within
view of the melancholy House of Usher. I know not how it was; / but, with the
first glimpse of the building, a sense of insufferable gloom pervaded my
spirit. / I say insufferable; for the feeling was unrelieved by any of that
half-pleasurable, because poetic/ , sentiment, with which the mind usually
receives even the sternest natural images of the desolate or terrible/ . I
looked upon the scene before me upon the mere house, and the simple landscape
features of / the domain upon the bleak walls upon the vacant eye-like
windows upon a few rank sedges and / upon a few white trunks of decayed trees
with an utter depression of soul which I can compare to / no earthly
sensation more properly than to the after-dream of the reveler upon opium the
bitter lapse / into every-day life the hideous dropping off of the veil.
Any further assistance would be GREATLY appreciated! Thank you! Was in your
beautiful Bavaria in June. It was just lovely.
Thanks again Helmut.
-
> Hi,
>
[quoted text clipped - 13 lines]
> the meaning of "word", like everything, is fuzzy,
> always more or less, and disputable.
Helmut Weber - 04 Oct 2005 17:38 GMT
Hi,
>Helmut, Thank you so much. This gets me very close to what I need.
I am really sorry to say so, getting closer would involve
a lot of tedious coding, an endless list of exceptions,
an very substantial reduction of performance,
and still only get you a bit closer.
Try this one, for gaining an impression
of what a word is to "Word".
Dim oWrd As Object
For Each oWrd In ActiveDocument.Words
oWrd.Select
Next
Try define, what isn't a word:
#.;,-_/&%$"!=?\'<>{}[]1234567890®±.........
Beware of O'Connor, Formula-1-Pilot, ¾-inch-pipe,
killer whale (one word), singer songwriter composer (one word),
according to what I've learned at university.
At least you'll get an impression, what "fuzzy" means.
No computer can decide between cold and worm,
early or late, fast or slow, good and bad...

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Greg - 04 Oct 2005 18:14 GMT
jbraden,
I think Helmut is correct that this could be very complex. However,
"if" you are careful with your spacing, you might get closer to your
desired result with:
Sub ScratchMacro()
Dim oChar As Range
Dim i As Long
For Each oChar In ActiveDocument.Range.Characters
If Asc(oChar) = 32 Then
i = i + 1
If i = 20 Then
oChar.InsertAfter "/"
i = 0
End If
End If
Next oChar
End Sub
Tony Jollans - 04 Oct 2005 19:15 GMT
What about doing this with Find and Replace?
Looking for strings delimited by space and/or carriage return would
approximate to natural language words.
Unfortunately, Word's pattern matcher throws up its hands in horror at what
it sees as over-complex search strings, so a little loop of repeated finds
is called for ...
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[! ^13]{1,}[ ^13]{1,}[! ^13]{1,}[ ^13]{1,}"
.Replacement.Text = "^&/ "
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Do
For i = 1 To 9
If Not Selection.Find.Execute Then Exit Do
Next i
If Not Selection.Find.Execute(Replace:=wdReplaceOne) Then Exit Do
Loop
--
Enjoy,
Tony
> jbraden,
>
[quoted text clipped - 15 lines]
> Next oChar
> End Sub