J
Joe Fawcett
Has anyone had problems with this? On two machines I have, both with latest
releases and sp1 for Ofiice 2003 the following code runs 'like a dog' and
hogs 100% of cpu cycles, even with no other user processes executing. The
letters come out very, very slowly. Usually the first line comes after a
long wait, the next part comes regularly as is hoped for.
Private Sub TypeString(str As String, delay As Long)
Dim iIndex As Long
Dim iStringLength As Long
Dim oDoc As Document
Set oDoc = ActiveDocument
Dim oRange As Range
Set oRange = oDoc.Content
oRange.Text = ""
iStringLength = Len(str)
For iIndex = 1 To iStringLength
oRange.Collapse wdCollapseEnd
oRange.Text = Mid$(str, iIndex, 1)
DoPause delay
Next iIndex
End Sub
Private Sub DoPause(secs As Long)
Dim fFinish As Single
fFinish = Timer + secs
Do While Timer < fFinish
DoEvents
Loop
End Sub
Public Sub ShowMessage()
TypeString "Happy New Year" & vbCrLf & "from" & vbCrLf & "Joe", 2
End Sub
I run ShowMessage via alt+F8 and double clicking list box entry.
Perhaps there is something else wrong with the code?
Thanks
releases and sp1 for Ofiice 2003 the following code runs 'like a dog' and
hogs 100% of cpu cycles, even with no other user processes executing. The
letters come out very, very slowly. Usually the first line comes after a
long wait, the next part comes regularly as is hoped for.
Private Sub TypeString(str As String, delay As Long)
Dim iIndex As Long
Dim iStringLength As Long
Dim oDoc As Document
Set oDoc = ActiveDocument
Dim oRange As Range
Set oRange = oDoc.Content
oRange.Text = ""
iStringLength = Len(str)
For iIndex = 1 To iStringLength
oRange.Collapse wdCollapseEnd
oRange.Text = Mid$(str, iIndex, 1)
DoPause delay
Next iIndex
End Sub
Private Sub DoPause(secs As Long)
Dim fFinish As Single
fFinish = Timer + secs
Do While Timer < fFinish
DoEvents
Loop
End Sub
Public Sub ShowMessage()
TypeString "Happy New Year" & vbCrLf & "from" & vbCrLf & "Joe", 2
End Sub
I run ShowMessage via alt+F8 and double clicking list box entry.
Perhaps there is something else wrong with the code?
Thanks