Non-style-based formatting within a paragraph

E

Edward Thrashcort

Word 2000/XP

Is there any way to select text within a paragraph that has ANY formatting
that's NOT part of the style for that paragraph?

Eddie Thrashcort
 
K

Klaus Linke

Hi Edward,

Right, no. At least no simple, built-in command that does anything like
that.

In Word2003, you have an option to "keep track of formatting". Manual
formatting is then treated much the same way as styles.
You can then select all occurrences of some type of manual formatting (say
"Arial" or "bold") at once (Word2003 allows multiple noncontiguous
selections) and do something with them. VBA support for multiple selections
doesn't exist though, unfortunately.

Word2003 also has XML support. If you need to detect manual formatting to
"tag" it for some custom export format, it may be simpler to start with that
XML and twiddle that (say, write a custom XSLT).

If you describe what you want to do after you have selected the manually
formatted text, maybe someone will have an idea how to do that in Word2000.

Regards,
Klaus
 
E

Edward Thrashcort

The job is for a client who has Word 2000 and Word XP.
They want it to work on both versions.

They want to extract contact data from hundreds of word documents and all
such data has in common that it has been highlighted in some way - eg change
of font, bold, italics, change of colour etc. Anything that's not Normal
font has been tweaked by hand because the original data was "spat-out" by a
computer at some time in the last 5 years and would therefore have been
Normal style (or plain-text or body-text etc).

I haven't tried this yet but maybe I could store all the characteristics of
the paragraph style and then us Find to search for things like

eg something on the lines of ....

With Selection.Find.Font
.Color = Not(wdColorRed)
End With

With Selection.Find.Font
.Color <> wdColorRed
End With


I'm not sure if you can search for the absence of something.
Also there would probably be a LOT of properties to search for.

If after finding and extracting some text, I then reverted it to the default
paragraph font, then this would prevent it from being selected more than
once because it was bold AND italic AND green


Eddie
 
K

Klaus Linke

Hi Eddie,
With Selection.Find.Font
.Color = Not(wdColorRed)
End With

With Selection.Find.Font
.Color <> wdColorRed
End With

That won't work, I'm afraid. In your case, I'd probably try to figure out
all the "highlighting" that has been used (bold, italic, highlighted,
color=red, ...) and search for that. Assuming that bold, italic,
highlighted, color=red .... haven't been used in the styles, that is.

To find (or tag) arbitrary manual formatting will be more difficult.

The way I do it is to make a copy of the document where all paragraph styles
look like Normal style:
myStyle.Font = ActiveDocument.Styles(wdStyleNormal).Font
myStyle.ParagraphFormat =
ActiveDocument.Styles(wdStyleNormal).ParagraphFormat

For character styles:
myStyle.Font = ActiveDocument.Styles(wdStyleNormal).Font

A document that originally was formatted wholly with character styles and
paragraph styles will now look like plain unformatted text with those style
definitions.

Any remaining formatting that is still applied (italic, bold, space before,
....) has been applied manually.

You'll still need to search for all kinds of formatting separately, but at
least you won't match bold headings when searching for bold, and so on.

Greetings,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top