M
MNT77
I've vrite code below to find and replace words in MSWord.
I've installed my application in a lot of PC and all works fine.
I've 2 PC with Win XP Pro and Office 200 Pro where this code run extremly
slow (minutes to replace 100 word).
When application run on this PC i see word and it is slow but if i click on
word window immedialy become fast. Help pls
The Code:
Private Sub Comando0_Click()
Dim WordApp As Word.Application
Set WordApp = New Word.Application
WordApp.Visible = True
Dim WordDoc As Word.Document
Set WordDoc = WordApp.Documents.Open("C:\TimeTest\doc2.doc")
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Dim i As Integer
For i = 0 To 100
Dim strFind As String
Dim strReplace As String
strFind = "Campo" & i + 1
strReplace = "Campo" & i + 2
With Selection.Find
.Text = strFind
.Replacement.Text = strReplace
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next
MsgBox "OK"
End Sub
I've installed my application in a lot of PC and all works fine.
I've 2 PC with Win XP Pro and Office 200 Pro where this code run extremly
slow (minutes to replace 100 word).
When application run on this PC i see word and it is slow but if i click on
word window immedialy become fast. Help pls
The Code:
Private Sub Comando0_Click()
Dim WordApp As Word.Application
Set WordApp = New Word.Application
WordApp.Visible = True
Dim WordDoc As Word.Document
Set WordDoc = WordApp.Documents.Open("C:\TimeTest\doc2.doc")
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Dim i As Integer
For i = 0 To 100
Dim strFind As String
Dim strReplace As String
strFind = "Campo" & i + 1
strReplace = "Campo" & i + 2
With Selection.Find
.Text = strFind
.Replacement.Text = strReplace
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next
MsgBox "OK"
End Sub