B
Bill E.
I could really use some help on this one!! Any suggestions
would be really appreciated.
Here's the task and the existing code.
Task: Locate in the document all "charcter" styles that
are in use. Record the found "paragraphs" in an array for
later use.
Existing Code: This works, it's unacceptable because of
the speed issue. (It's God Awful Slow).
-----------------------------------------------------------
---------------------
With ActiveDocument.Styles
For lngI = 1 To .Count
If .Item(lngI).Type = wdStyleTypeCharacter Then
strCharStyle = .Item(lngI)
If .Item(lngI).InUse Then
With ActiveDocument.Content.Find
.Style = strCharStyle
' Loop through to denote all
paragraphs that contain
' this style.
Do While .Execute(FindText:="",
Forward:=True, _
Format:=True) = True
' If we found it...
If .Found = True Then
.Parent.Select
For lngJ = 1 To
ActiveDocument.Paragraphs.Count
If Selection.InRange( _
ActiveDocument.Paragraphs(lngJ).Range) _
Then
' Record the
location of the paragraph
' with the
character style.
arrCharacterstyleParas(lngJ) = True
Exit For
End If
DoEvents
Next
End If
Loop
End With
End If
End If
Next
End With
-----------------------------------------------------------
---------------------
The problem is that once we've found a character style in
use in the document we have to determine which paragraph
in the paragraphs collection it's in. The only way I've
found to do this is to iterate through the entire
paragraphs collection testing selection.inrange() for each
until we found it.
Please, someone help. I'm dyin here.....
Bill
would be really appreciated.
Here's the task and the existing code.
Task: Locate in the document all "charcter" styles that
are in use. Record the found "paragraphs" in an array for
later use.
Existing Code: This works, it's unacceptable because of
the speed issue. (It's God Awful Slow).
-----------------------------------------------------------
---------------------
With ActiveDocument.Styles
For lngI = 1 To .Count
If .Item(lngI).Type = wdStyleTypeCharacter Then
strCharStyle = .Item(lngI)
If .Item(lngI).InUse Then
With ActiveDocument.Content.Find
.Style = strCharStyle
' Loop through to denote all
paragraphs that contain
' this style.
Do While .Execute(FindText:="",
Forward:=True, _
Format:=True) = True
' If we found it...
If .Found = True Then
.Parent.Select
For lngJ = 1 To
ActiveDocument.Paragraphs.Count
If Selection.InRange( _
ActiveDocument.Paragraphs(lngJ).Range) _
Then
' Record the
location of the paragraph
' with the
character style.
arrCharacterstyleParas(lngJ) = True
Exit For
End If
DoEvents
Next
End If
Loop
End With
End If
End If
Next
End With
-----------------------------------------------------------
---------------------
The problem is that once we've found a character style in
use in the document we have to determine which paragraph
in the paragraphs collection it's in. The only way I've
found to do this is to iterate through the entire
paragraphs collection testing selection.inrange() for each
until we found it.
Please, someone help. I'm dyin here.....
Bill