S
Stephen Gray
To speed up a Word report ( using VB ) I'm trying to get a table per
page rather then one big table as they have previously. The table has
over 11,000 lines on it so it gets slower and slower. I’ve managed
to create one table per page ( which speeds up the report a lot ) but
the problem that I need to apply the clearFormatting to each row in
order to get it’s correct size ( so I can see if I need a new table
or not ). Previously the developer was able could do this for the
whole table but now I have to do it on a row my row basis. Below is
one a routine that they used previously on the table. The problem is
that this call gets slower and slower, even though I’m working on
only one row at a time. That is if I run the code for the first table
it runs through about 10 rows per second but if I say apply it to table
20 ( on page 20 ) it then only handles 1 possibly 2 a second.
I also tried using RegExp to do the removal for me which was fast but
sadly it removed the formatting ï‹
Any help would be appreciated !
Private Sub mpTrimRow(ByVal oRow As Word.Row)
Const cProcedure As String = "mpTrimRow"
On Error GoTo Handler
With oRow.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.text = "^p" ' remove surplus CR
.Replacement.text = ""
.Forward = True
' .Wrap = wdFindContinue ' 12/05/03
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
With oRow.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.text = "\{*\}" ' remove formatting commands using wildcard
.Replacement.text = ""
.Forward = True
' .Wrap = wdFindContinue ' rw 12/05/03
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True ' must be true to find wildcard
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Handler:
Throw Err, cMODULE, cProcedure
Exit Sub
End Sub
page rather then one big table as they have previously. The table has
over 11,000 lines on it so it gets slower and slower. I’ve managed
to create one table per page ( which speeds up the report a lot ) but
the problem that I need to apply the clearFormatting to each row in
order to get it’s correct size ( so I can see if I need a new table
or not ). Previously the developer was able could do this for the
whole table but now I have to do it on a row my row basis. Below is
one a routine that they used previously on the table. The problem is
that this call gets slower and slower, even though I’m working on
only one row at a time. That is if I run the code for the first table
it runs through about 10 rows per second but if I say apply it to table
20 ( on page 20 ) it then only handles 1 possibly 2 a second.
I also tried using RegExp to do the removal for me which was fast but
sadly it removed the formatting ï‹
Any help would be appreciated !
Private Sub mpTrimRow(ByVal oRow As Word.Row)
Const cProcedure As String = "mpTrimRow"
On Error GoTo Handler
With oRow.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.text = "^p" ' remove surplus CR
.Replacement.text = ""
.Forward = True
' .Wrap = wdFindContinue ' 12/05/03
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
With oRow.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.text = "\{*\}" ' remove formatting commands using wildcard
.Replacement.text = ""
.Forward = True
' .Wrap = wdFindContinue ' rw 12/05/03
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True ' must be true to find wildcard
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Handler:
Throw Err, cMODULE, cProcedure
Exit Sub
End Sub