Searching for formats

K

Kuko

Hi.

I've received six huge (400+ pages) documents from a friend. There
is a typing mistake which appears quite often, and consists in the
fact that the word right after an italic or boldfromatted word are
"attached" to it (i. e., he didn't typed the space). Graphically, the
typing error is the following (being the text enclosed in "_" the
italic or bold formated word):

_blablabla_moreblablabla

The document is full of technical terms, so it is not clever to use
the spell checker. There is a way to search for an "italic+nonitalic"
and "bold+notbold" (without spaces between them) pieces of text? It'll
be nice.

I'm on Word 2000 (SP 3).

TIA
 
D

Doug Robbins

Use the following code in a macro

Dim myrange As Range, Flag As Boolean
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Font.Italic = True
Do While .Execute(FindText:="^$", Format:=True, MatchWildcards:=False,
Wrap:=wdFindStop, Forward:=True) = True
Set myrange = Selection.Range
Flag = True
While Flag = True
myrange.End = myrange.End + 1
If myrange.Characters(myrange.Characters.Count).Font.Italic =
False Then
Flag = False
End If
Wend
myrange.End = myrange.End - 1
myrange.Text = myrange.Text & " "
Selection.MoveRight Unit:=wdWord
Loop
End With


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

Kuko

On Fri, 26 Aug 2005 21:57:44 +0200, "Doug Robbins"

Hi Doug. Thank you for your interest. The macro is very spectacular
at work. It somewhat separates pieces of text with italic and regular
characters, but for some reason it messed up totally the documents
(which I don't saved LOL), esp. the TOCs and bibliography sections
(which contain a lot of italics).

I uploaded a capture with the result on a TOC at
http://img363.imageshack.us/img363/251/toc8jt.png
Maybe it should help you if you want to fix it. Basically the macro
does what in the image happened to the separator character on the TOC
entries everywhere it sees italic + regular.

Regards
 
J

Jezebel

Here's another approach:

1. Search for: leave blank, set formatting to italic. Replace with: ^&XXX
where 'XXX' is any string that doesn't otherwise occur in your document.

2. With 'Wildcards' checked, search for: XXX([a-z0-9]) Replace with:
[space]\1 (use an actual space in place [space])

3. Clear wildcards. Search for XXX Replace with nothing.
 
D

Doug Robbins

If your table of contents is a real table of contents (i.e. a field) then if
you update it, it should revert to what it was.

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