> Hi,
>
> Thanx for your reply...
>
> I've tested the build in features you mentioned but it does not work well.
Doesn't work well how? It seems to me it works all too well :)
> Also, the VBA code I'm trying to develop and I'm looking for, will be used
> in Word prior to 2003.
In that case, you've got a sh.t-load of work to do. Probably simplest is
along these lines:
1. Iterate the paragraphs of the document.
2. Compare the paragraph's formatting features with those of the underlying
style. There are three possibilities --
a) They match
b) They are set to something else.
c) They are 'undefined', meaning that the paragraph contains mixed values.
For text properties (like the style name), undefined is given as an empty
string. For numeric values (like type size) undefined is given as 999999
(check how many nines, but I think it's six).
3. If the paragraph contains mixed formatting, iterate its characters and
text them individually.
John Devlon - 26 Jan 2005 23:50 GMT
Dear Jezebel,
Many thanx for your feedback...
I already developed some basic code ... And this works fine... Afcourse this
has to be extended...
One thing i noticed is that when paragraph styles are mixed with character
formating, the code does not detect any mistakes... Do you have any
suggestions how i can detect these occurenses ... I can not find any
'undefined' ...
Thanx
John
Sub Controle_Styles()
Dim Sty1 As String
Dim bolFound As Boolean
bolFound = False
Dim acceptedStyle(10) As String
acceptedStyle(1) = "[text]"
acceptedStyle(2) = "[ht]"
acceptedStyle(3) = "[t1]"
For Each para In ActiveDocument.Paragraphs
Sty1 = para.Style
For i = 0 To UBound(acceptedStyle)
If acceptedStyle(i) = Sty1 Then
bolFound = True
End If
Next
If bolFound = False Then
para.Style = ActiveDocument.Styles("[FOUT]")
End If
bolFound = False
Next para
End Sub
>> Hi,
>>
[quoted text clipped - 27 lines]
> 3. If the paragraph contains mixed formatting, iterate its characters and
> text them individually.
Jezebel - 27 Jan 2005 00:19 GMT
You'll need to be more thorough in your checking. At present you're checking
only the name of the style. You need to check the properties also --
Dim pStyle as Word.Style
Set pStyle = ActiveDocument.Styles("[text]")
With para.Range.Font
If .Bold = 9999999 then
... contains mixed values
elseif .Bold <> pStyle.Font.Bold then
... differs from definition
... etc. Repeat for font name, size, italic, etc etc, etc
With para.Range.ParagraphFormat
With para.Range.Borders
With para.Range.ListFormat
etc
As I said, you have a heap of work to do if you want to be thorough.
> Dear Jezebel,
>
[quoted text clipped - 71 lines]
> > 3. If the paragraph contains mixed formatting, iterate its characters and
> > text them individually.