M
marcelk
Hi,
I'm testing all the macros our company is using. They are build under Word
2003 and now I'm testing them in Word 2007. A lot is working as it should
however in one particual case the vba code behaves strange. In the next vba
code I add every time a paragraph and checks if the cursor is on the right
level. When running the macro, Word is hanging and the only solution is to
quit the process. When I run the macro in debug mode and step through the
code with F8 it works as expected. Is there a kind of timing problem? I added
some debug statements to see where it stops.
Public Sub AlineasInvoegenTotAanRegel(n As Integer)
Dim i As Integer, pos As Single, pos1 As Integer
Debug.Print "17n1"
pos = Selection.Information(wdVerticalPositionRelativeToPage)
pos1 = Round(pos / 13)
Do While pos1 < (n - 1)
Debug.Print "n: " + n
Debug.Print "17n2"
Selection.TypeParagraph
pos = Selection.Information(wdVerticalPositionRelativeToPage)
pos1 = Round(pos / 13)
Debug.Print "Pos: " + Str(pos)
Debug.Print "Pos1: " + Str(pos1)
Loop
Debug.Print "17n3"
End Sub
I'm testing all the macros our company is using. They are build under Word
2003 and now I'm testing them in Word 2007. A lot is working as it should
however in one particual case the vba code behaves strange. In the next vba
code I add every time a paragraph and checks if the cursor is on the right
level. When running the macro, Word is hanging and the only solution is to
quit the process. When I run the macro in debug mode and step through the
code with F8 it works as expected. Is there a kind of timing problem? I added
some debug statements to see where it stops.
Public Sub AlineasInvoegenTotAanRegel(n As Integer)
Dim i As Integer, pos As Single, pos1 As Integer
Debug.Print "17n1"
pos = Selection.Information(wdVerticalPositionRelativeToPage)
pos1 = Round(pos / 13)
Do While pos1 < (n - 1)
Debug.Print "n: " + n
Debug.Print "17n2"
Selection.TypeParagraph
pos = Selection.Information(wdVerticalPositionRelativeToPage)
pos1 = Round(pos / 13)
Debug.Print "Pos: " + Str(pos)
Debug.Print "Pos1: " + Str(pos1)
Loop
Debug.Print "17n3"
End Sub